简体   繁体   中英

Event on Application Minimized in C++ Windows API

Is there a signal or event in the Windows Desktop API that can tell me if my application is in a minimized state? I looked through msdn documentation and have only found minimize events that call as the application is minimizing, not when the application is already done the minimize and in a final minimized state.

I need to set another operation off ( a screen capture) when I know the window that I set is minimized and out of the way of the screen capture. I use the WM_SIZE message to check the window is minimized, then start the screen capture. My problem is that I can still see the application window closing when the screen capture is taken (ie the minimization animation done by most application windows), even though I got a SIZE_MINIMIZED message through a ProcessWindowMessage callback. I need something to tell me that the application is fully minimized, and not in the way of the screen capture I am taking of the entire desktop.

Thanks!

You probably want IsIconic() ; if your window is minimized that API will return non-zero.

I believe you are looking for the WM_SIZE message. It will be sent after the window's size has changed. If you window was minimised the wParam variable should be equal to SIZE_MINIMIZED

You can try the solution mentioned here: How could I detect when my application is minimized?

~snip:

switch (message)
{
case WM_SYSCOMMAND:
    if ((wParam & 0xFFF0) == SC_MINIMIZE)
    {
        // shrink the application to the notification area
        // ...

        return 0;
    }
    break;
}

Or try the GetWindowPlacement function: https://msdn.microsoft.com/en-us/library/windows/desktop/ms633518(v=vs.85).aspx

~snip

Retrieves the show state and the restored, minimized, and maximized positions of the specified window.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM