Reputation: 8981
I want to create a Spotify-like behavior for my WPF application. When the application is running, but minimized in the taskbar and the user tries to start a new instace, it should restore it from the taskbar, and give focus to the already running instance. The problem is stumble upon is to open to application from minimized state in the taskbar to be in focus. It works if the application is open, but other windows are placed over it.
var processHndl = FindWindow(null, "MyApplicationName!");
if (processHndl != IntPtr.Zero)
{
var isIconic = IsIconic(processHndl);
MessageBox.Show("Iconic: " + isIconic);
if (IsIconic(processHndl))
{
ShowWindow(processHndl, 9);
}
SetForegroundWindow(processHndl);
}
Any ideas?
Upvotes: 0
Views: 193