I know about the contract between Windows Owners and their Owner and that Own windows are hidden when the Owner is hidden. This is actually what I want. The problem is that if you show the Owned window after the Owner window is minimized, the Owned window will not be hidden, but it will display normally on the screen. In this case, the WindowState of the window is minimized at startup, so any displayed window that is displayed is displayed on the screen.
I know that I can call ShowOwnedPopups to make the OS hide all its own windows, but this only seems to work after the Owned window actually shows that you are seeing flickering on the screen. I tried to explicitly hide the window (for example, by removing the WS_VISIBLE bit or trying to change WM_SHOWCOMMAND so that it was hidden), but then the Owned window does not become visible when the owner is restored. This is consistent with the documentation for the ShowOwnedPopups API, in which the only windows that become visible are hidden calls to ShowOwnedPopups.
So, I'm looking for a way for the OS to display the window so that it is not visible to the end user until the owner is restored - or - a way to set a flag in the window so that the OS thinks it is hiding the window using ShowOwnedPopups, and then I will manually hide the window and set this flag.
Please note that the code that displays the Own windows is not associated with the shell, so it’s not easy not to show the owned window until the owner is restored. This is part of a separate custom control, in which case it is a WPF control, so the control can even be used in ElementHost, so I can’t just watch WindowState in its own window. Any Windows API solution is welcome.
source share