I\'m adding some code to an app that will launch another app if it isn\'t already running, or if it is, bring it to the front. This requires a small amount of interop/WinAPI
I had the same problem. The best solution I have found is to call ShowWindow
with the flag SW_MINIMIZE
, and then with SW_RESTORE
. :D
Another possible solution:
// Code to display a window regardless of its current state
ShowWindow(hWnd, SW_SHOW); // Make the window visible if it was hidden
ShowWindow(hWnd, SW_RESTORE); // Next, restore it if it was minimized
SetForegroundWindow(hWnd); // Finally, activate the window
from comments at: http://msdn.microsoft.com/en-us/library/ms633548%28VS.85%29.aspx