Restore a minimized window of another application

前端 未结 6 1165
情深已故
情深已故 2020-11-27 17:00

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

6条回答
  •  春和景丽
    2020-11-27 17:49

    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

提交回复
热议问题