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.

lSingleInstance - How to activate the application?

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

lSingleInstance - How to activate the application?

Mensaje 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
Developments | Trainings | Projects
Site | E-mail | Messenger | YouTube
Avatar de Usuario
ignacio
Site Admin
Mensajes: 9246
Registrado: Lun Abr 06, 2015 8:00 pm
Ubicación: Madrid, Spain
Contactar:

Re: lSingleInstance - How to activate the application?

Mensaje 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
Ignacio Ortiz de Zúñiga
[Equipo de Xailer / Xailer team]
https://www.xailer.com
Avatar de Usuario
Hurricane
Mensajes: 262
Registrado: Mar Mar 24, 2015 10:21 am
Ubicación: Brasil
Contactar:

Re: lSingleInstance - How to activate the application?

Mensaje 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. :(
Developments | Trainings | Projects
Site | E-mail | Messenger | YouTube
Avatar de Usuario
ignacio
Site Admin
Mensajes: 9246
Registrado: Lun Abr 06, 2015 8:00 pm
Ubicación: Madrid, Spain
Contactar:

Re: lSingleInstance - How to activate the application?

Mensaje 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.
Ignacio Ortiz de Zúñiga
[Equipo de Xailer / Xailer team]
https://www.xailer.com
Avatar de Usuario
Hurricane
Mensajes: 262
Registrado: Mar Mar 24, 2015 10:21 am
Ubicación: Brasil
Contactar:

Re: lSingleInstance - How to activate the application?

Mensaje por Hurricane »

You made the adjustment in Xailer, now works as expected.

Thanks.
Responder