Page 1 of 1

How to activate minimized program?

Posted: Tue Aug 25, 2009 4:01 pm
by dutch
Dear All,

I cannot find this topic, it might off topic.
I want to activate the minimized program from system tray. It means "Allow to run program once only".

Regards,
Dutch

Re: How to activate minimized program?

Posted: Tue Aug 25, 2009 7:23 pm
by Enrico Maria Giordano
Try oWnd:Normal().

EMG

Re: How to activate minimized program?

Posted: Wed Aug 26, 2009 4:09 am
by dutch
Dear EMG,

I'm sorry to explain unclearly. I need to activate the program when the user dblclick on shortcut if program has been minimized. It will protect the user open program more than one.

Regards,
Dutch

Re: How to activate minimized program?

Posted: Wed Aug 26, 2009 5:29 am
by Loach
Hello, Dutch!
In my programs I did it such way:

Code: Select all

if IsExeRunning( 'dispan.exe' ).or.IsExeRunning( 'Dispan.exe' ).or.IsExeRunning( 'DISPAN.exe' ).or.IsExeRunning('DISPAN.EXE' )
   if pppp()==1
      msgstop('Program is already running.','Ups...')
   endif
   return .f.
endif
 
in the start of program. And this is function PPP:

Code: Select all

#PRAGMA BEGINDUMP
#include "Windows.h"
#include "ClipApi.h"

HB_FUNC( PPPP )
{
HWND hWnd;  
if (hWnd=FindWindow(NULL,"Clinical examination""))
       {
        ShowWindow(hWnd,SW_RESTORE);
        SetForegroundWindow(hWnd);
        _retni(0);
       }
_retni(1);
}
#PRAGMA ENDDUMP
Where "Clinical examination" is the name of main window in program.

Re: How to activate minimized program?

Posted: Wed Aug 26, 2009 5:48 am
by RAMESHBABU
Hi Mr.Dutch,

Even the following code also works.

Code: Select all


SetForeGroundWindow(oWnd)

***************************************************************************************************
*** SetForeGroundWindow( hWnd ) to Bring the Minimised window to ForeGround ***
***                             When the user try to execute it again                                ***
***************************************************************************************************

DLL32 FUNCTION SetForeGroundWindow( hWnd AS LONG ) AS BOOL;
PASCAL FROM "SetForegroundWindow" LIB "user32.dll"
 
- Ramesh Babu P

Re: How to activate minimized program?

Posted: Wed Aug 26, 2009 11:47 am
by nageswaragunupudi
Mr Dutch

The above suggestions are good.

You may also like to see "showapp.prg" in the samples folder of fwh.
This sample program answers your requirement exactly

Re: How to activate minimized program?

Posted: Wed Aug 26, 2009 12:15 pm
by dutch
Dear Rao and All,

Thanks, all solution is working great. ShowApp.prg is the one that I'm looking for.

Regards,
Dutch