In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.

Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.

how to activate the window?

Xailer English public forum
Responder
Avatar de Usuario
Hurricane
Mensajes: 262
Registrado: Mar Mar 24, 2015 10:21 am
Ubicación: Brasil
Contactar:

how to activate the window?

Mensaje por Hurricane »

If I minimize Form1 to instantiate and display Form2, the window is displayed but without giving the focus, it is necessary to click.

Original test:

Código: Seleccionar todo

METHOD Button1Click( oSender ) CLASS TForm1   
   ::Minimize()
   with object TForm2():New(self)
      :ShowModal()
   end with   
   ::Restore()
   RETURN Nil
other unsuccessful attempts:

Código: Seleccionar todo

METHOD Button1Click( oSender ) CLASS TForm1   
   with object TForm2():New(self)
      ::Minimize()
      :setFocus() 
      :ShowModal()
   end with   
   ::Restore()
   RETURN Nil
In form2:

Código: Seleccionar todo

METHOD FormInitialize( oSender ) CLASS TForm2
   LogDebug(Application:oActiveForm:className) // TForm1
   ::oEdit1:SetFocus()
RETURN Nil
more information:
1-the onActive event was run
2-the edit displays the cursor blinking (and the form is not active)

Código: Seleccionar todo

METHOD FormActivate( oSender, oCtl ) CLASS TForm2
   LogDebug( 'active' )
   RETURN Nil
Avatar de Usuario
jfgimenez
Site Admin
Mensajes: 5706
Registrado: Lun Abr 06, 2015 8:48 pm
Contactar:

Re: how to activate the window?

Mensaje por jfgimenez »

Try

Código: Seleccionar todo

SetForegroundWindow( ::Handle )
::SetFocus()
José F. Giménez
[Equipo de Xailer / Xailer team]
http://www.xailer.com
http://www.xailer.info
Avatar de Usuario
Hurricane
Mensajes: 262
Registrado: Mar Mar 24, 2015 10:21 am
Ubicación: Brasil
Contactar:

Re: how to activate the window?

Mensaje por Hurricane »

The window is activated, but no control receives focus automatically.

As I have to give focus to the first data control (not knowing which), I had to create an xSetFocus only for this form, because in this situation GoFirstControl() also does not help.

Código: Seleccionar todo

   ::minimize()
   with object TFrmAny():New(self)
      ...
      //:GoFirstControl() // Does not work
      :xSetFocus()        // activates the window and the first data control
      :ShowModal()
   end with
   ::restore()
jfgimenez escribió:Try

Código: Seleccionar todo

SetForegroundWindow( ::Handle )
::SetFocus()
Responder