0

Does anyone know how to restore a window (which does not belong to current process) to the state is was in previous to having been minimized?

I've been trying ShowWindow and SetForegroundWindow, but if the window was maximized, it will only restore it to it's RESTORE state (not maximized)

ShowWindowAsync(hWnd, SW_SHOW);
SetForegroundWindow(hWnd);

I have tried every flag for nCmdShow, but none work, and I've tried ShowWindow with them all as well as ShowWindowAsync.

3
Contributors
5
Replies
18
Views
4 Years
Discussion Span
Last Post by Ancient Dragon
0

Untested, but this should work provided you're running in the same session as the target process.

if (!IsWindowVisible(hWnd))
{
    ShowWindow(hWnd, SW_MINIMIZE);
    ShowWindow(hWnd, SW_RESTORE);
}

SetForegroundWindow(hWnd);

Edited by nullptr: typo

0

Thank's for taking the time to reply nullptr.
Unfortunately, this does not activate and show the window if it is minimized.

0

This appears to work fine.

SetForegroundWindow(hWnd);
if (!IsWindowVisible(hWnd) || IsIconic(hWnd))
{     
    ShowWindow(hWnd, SW_MINIMIZE);
    ShowWindow(hWnd, SW_RESTORE);
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.