How to restore my application instead of running a new instance?
-
How to restore (maximize) my application instead of running a new instance when another instance is already running?
You could try to define a hook to maximize your app when you do smtg ... Or you could hit ALT-TAB :)
-
How to restore (maximize) my application instead of running a new instance when another instance is already running?
-
How to restore (maximize) my application instead of running a new instance when another instance is already running?
Somehow, before you create your app window, you need to find if another instance is running. One way is to use a named mutex that each instance tries to aquire. Another is to use the main window text as shown below (although not the suggested method) :
HWND h = ::FindWindowW(AppName, NULL);
if( h ) {
// Set focus to foremost child window.
// The "| 0x01" is used to bring any owned windows to the
// foreground and activate them.
::SetForegroundWindow( (HWND)((ulong)h|0x00000001) );
return(true);
}The key point in the above is not finding the app window, but how to restore it once found. ...cmk Save the whales - collect the whole set