Link to home
Start Free TrialLog in
Avatar of skynergy
skynergy

asked on

Bring previous application instance to front

I hide my application to the system tray, then try to prevent another instance of the application to be run but are unable to bring the first instance to the front again.

Here is my code to hide the application to the system tray:
  ShowWindow(Application.Handle, SW_HIDE);
  ShowWindow(Application.MainForm.Handle, SW_HIDE);

to prevent I use:
  Mutex := CreateMutex(nil, False, AppTitle);
  if (GetLastError = ERROR_ALREADY_EXISTS) or
     (Mutex = 0) then
     Application.Terminate;

But how do I bring my previous instance of my application to the front?

Thanx in advance!
Avatar of Lukasz Zielinski
Lukasz Zielinski
Flag of Poland image

You have to use FindWindow() to find handle of main form of previous instance and then call ShowWindow()
ziolko.
ASKER CERTIFIED SOLUTION
Avatar of DaFox
DaFox

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial