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
User avatar
Hurricane
Posts: 85
Joined: Tue Mar 24, 2015 10:21 am
Location: Brasil
Contact:

how to activate the window?

Postby Hurricane » Wed May 09, 2018 9:01 pm

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:

Code: Select all

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

other unsuccessful attempts:

Code: Select all

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

In form2:

Code: Select all

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)

Code: Select all

METHOD FormActivate( oSender, oCtl ) CLASS TForm2
   LogDebug( 'active' )
   RETURN Nil
User avatar
jfgimenez
Site Admin
Posts: 5568
Joined: Mon Apr 06, 2015 8:48 pm
Contact:

Re: how to activate the window?

Postby jfgimenez » Thu May 10, 2018 9:34 pm

Try

Code: Select all

SetForegroundWindow( ::Handle )
::SetFocus()
José F. Giménez
[Equipo de Xailer / Xailer team]
http://www.xailer.com
http://www.xailer.info
User avatar
Hurricane
Posts: 85
Joined: Tue Mar 24, 2015 10:21 am
Location: Brasil
Contact:

Re: how to activate the window?

Postby Hurricane » Fri May 11, 2018 6:58 pm

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.

Code: Select all

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

jfgimenez wrote:Try

Code: Select all

SetForegroundWindow( ::Handle )
::SetFocus()

Return to “English”