Reputation: 6259
At some users of my application, some WPF Windows will be shown behind the Shellwindow. This occurs only on some places. The Shellwindow does not has set Topmost. I hope someone could give me a tip, what I can do to prevent this.
Thanks.
Best Regards, thomas
Upvotes: 0
Views: 223
Reputation: 941515
There are only three scenarios that I know of where one of your windows could lose the focus and disappear behind the window of another app:
a program calling SetForegroundWindow() to shove one of its windows into the foreground. Windows has specific counter-measures against this since ~Win98, a user interface crime that was committed too often. It only permits this if it hasn't detected any input events in the active window for a while. It will blink the taskbar button otherwise. Of course, programmers have found counter-counter-measures. A version of Windows Update started doing this roughly two years ago. Luckily the programmer that was responsible for that was taken outside and shot.
the self-inflicted kind, triggered by for a short time having none of your windows being capable of receiving the focus. The Windows window manager is forced to find another window to give the focus to. That may well be a 'shell window', whatever is handy. You get this most typically when displaying a dialog and either hiding your main window or disabling it yourself. And showing it again when the dialog is closed. That's too late, there's a fraction of a second where no window can get the focus. It doesn't repeat well btw, not in the least because it depends what other window might be available.
displaying a toplevel non-owned window on a thread. Such a window cannot have any Z-order relationship with the other windows in your app and only has the desktop window as the parent. Where it competes with any other window, including windows owned by Explorer. Getting it shown on top of other windows is a crap-shoot, one that usually works but sometimes doesn't. Especially painful for the user when it is a message box.
Upvotes: 3
Reputation: 34240
You can set the Window.Owner
of secondary windows to the main window to avoid child windows appearing behind the main window. I am assuming this is what you mean by the shell window.
Here are some consequences of doing this (from the documentation):
Upvotes: 2