Página 1 de 1

lSingleInstance - How to activate the application?

Publicado: Jue Abr 30, 2015 5:28 am
por Hurricane
Run the first instance of the application and leave maximized (or inactive).
I run the application again, it is not activated, continues minimized (or inactive).

Código: Seleccionar todo

#include "Xailer.ch"

Procedure Main()
   Application:cTitle := "xtestex" // mutex
   Application:lSingleInstance := .T.

   TForm1():New( Application ):Show()
   Application:Run()

   Return
ps:
form:lAppWindow:=.t.
Xailer 4/Windows 7 64 bits

Re: lSingleInstance - How to activate the application?

Publicado: Jue Abr 30, 2015 11:43 am
por ignacio
Hello,

I'm afraid that is not an easy tasks since we can not easily access to the iconized app from the new app running. The only way to accomplish it is finding the window by its name:

Código: Seleccionar todo

METHOD FormInitialize( oSender ) CLASS TForm1

   BEGIN SEQUENCE
      Application:lSingleInstance := .t.
   RECOVER
      ::Close( .t. )
       ShowWindow( GetWndHnd("Form caption" ), SW_SHOWNORMAL )
   END SEQUENCE
   
RETURN Nil

#pragma BEGINDUMP
#include <windows.h>
#include <xailer.h>
XA_FUNC( GETWNDHND )
{
HWND hWnd;
hWnd = FindWindow(NULL, hb_parc( 1 ));
hb_retnl ((long) hWnd );
}
#pragma ENDDUMP

Re: lSingleInstance - How to activate the application?

Publicado: Jue Abr 30, 2015 4:23 pm
por Hurricane
Thank you for your help.
The title of the window is not an efficient way, the most appropriate is via mutex, routines included in Xailer also.

According to the documentation, the Xailer should automatically activate the first instance, but that's not what is happening. :(

Re: lSingleInstance - How to activate the application?

Publicado: Jue Abr 30, 2015 4:57 pm
por ignacio
Hurricane escribió:Thank you for your help.
The title of the window is not an efficient way, the most appropriate is via mutex, routines included in Xailer also.

According to the documentation, the Xailer should automatically activate the first instance, but that's not what is happening. :(
You are right: bad documented. We wil fix it ASAP. Thank you for your feedback.

Re: lSingleInstance - How to activate the application?

Publicado: Sab May 09, 2015 3:03 am
por Hurricane
You made the adjustment in Xailer, now works as expected.

Thanks.