Page 1 of 1

Windows Vista

PostPosted: Fri Aug 10, 2007 1:03 pm
by clemerson
Hi,

I access my system and to leave it, enter again and I say that this open granddaughter function... I give a time and I obtain to enter again, happens to each 10 attempts a time.

oWnd:=FindWindow( 0, "Sistema - SysFar" )
If oWnd!=0
MsgAlert("O Programa SysFar já se encontra aberto ...","Informação !!!")
BringWindowToTop( oWnd )
Return(.f.)
Endif

I use fwh 7.01

Clemerson

PostPosted: Fri Aug 10, 2007 9:00 pm
by Antonio Linares
Clemerson,

You could use an else just to check if the code fails sometimes:
Code: Select all  Expand view
hWnd:=FindWindow( 0, "Sistema - SysFar" )
If hWnd!=0
   MsgAlert("O Programa SysFar já se encontra aberto ...","Informação !!!")
   BringWindowToTop( hWnd )
   Return(.f.)
else
   MsgAlert( "can't find the main window" )
Endif

check it

PostPosted: Fri Aug 10, 2007 11:08 pm
by derpipu
IF findWindow( 0,oApp:cEmpresa + oApp:cSistema) > 0
MsgWait( "Atención, el Programa ya está abierto...", oApp:cEmpresa + oApp:cSistema ); QUIT
ENDIF


Regards

Luis Fernando Rubio Rubio
Tequila, Jalisco, Mexico.

PostPosted: Mon Aug 13, 2007 3:59 pm
by clemerson
ok, I go to make plus these tests...

Clemerson

PostPosted: Thu Aug 16, 2007 1:05 pm
by Rossine
Olá Clemerson,

Veja se é isto que você precisa:

Code: Select all  Expand view

#include "FiveWin.ch"

function Main

   local oWnd

   if IsExeRunning( cFileName( HB_ARGV( 0 ) ) )
      msgstop( "Este programa ja esta sendo executado !!!" )
      ShowApplication()
   else
      DEFINE WINDOW oWnd TITLE "Teste"

      ACTIVATE WINDOW oWnd
   endif
   
return nil

function ShowApplication

   local hWnd := FindWindow( 0, "Teste" )

   if hWnd != nil
      showwindow( hWnd, 0 )
      showwindow( hWnd, 6 )
      showwindow( hWnd, 9 )
   endif

return nil


Abraços,

Rossine.