In Windows, a Window can be made topmost, by setting an extended style with the value WS_EX_TOPMOST (8), typically provided to CreateWindowEx. A topmost window is always on top of non-topmost windows. Among all topmost windows, the normal z-order rules apply. That is, until Windows 8.
A Metro application is built with a topmost window – that makes perfect sense. What about desktop apps? Here’s an empty desktop snapped with a metro app (the desktop itself can be seen as a kind of metro app):
Now let’s open Task Manager and make it topmost (Options / Always On Top). Slide it across the dividing snap bar and Task Manager is happy to be on top of the metro app:
Curiously, clicking on the metro app window does not make Task Manager any less topmost. Now let’s open Process Explorer and make it topmost as well (Options / Always On Top). Slide it over the metro app window, and this is the result:
It seems its topmost attribute is less powerful than Task Manager’s or the metro window! That’s certainly a surprise. It turns out Task Manager is “special” – I couldn’t find any other window that can stay on top of a metro app window – or on top of Task Manager for that matter.
Maybe Task Manager has a new “secret” style bit that makes it “super topmost”. Let’s open Spy++ and select Spy / Find Window from the menu:
Dragging the “Finder Tool” over Task Manager’s main window and clicking ok, shows this in the Styles tab:
The extended style is 0x108, which is WS_EX_TOPMOST | WS_EX_WINDOWEDGE – the latter being a minor appearance adjustment, irrelevant for our purposes. It looks like a regular WS_EX_TOPMOST. Let’s try the same with the Metro window.
Dragging the Finder Tool over the metro window “doesn’t stick” for some reason. Dragging Process Explorer’s equivalent tool manages to pinpoint the process to which this window belongs (WWAHost.exe, meaning that app was written in HTML/JS), but it doesn’t give out the window handle. So, how can we get the window handle of that metro app?
I decided to try calling the simple WindowFromPoint function, that I’m pretty sure Process Explorer uses as well (I was also sure Spy++ does that, though I can’t understand why it fails to see the window):
That worked. I got a handle and typed it into Spy++ handle text box. It turns out this window is a child window, so I navigated to its parent (that window’s name was “Store”) and finally to its parent with is the top level window. These are its properties:
The only extended style is WS_EX_TOPMOST. How about Process Explorer’s window?
Pretty much the same. So they all have the same extended style bit (WS_EX_TOPMOST), but Task Manager and the Metro window behave as “super topmost” in relation to other topmost windows. Task Manager’s window seems to be the strongest topmost ever. So far, I don’t know how that is configured.