If my window has the 'always on top' extended style set, I would expect it to be on top of all windows that do not have the 'Always on top' style set and those windows that have the 'Always on top' style set but were activated before my window was activated.
To test this feature, I open the task manager window - set it to always on top and then I open my window (myWindow
).
In Windows 7, I observe the expected behaviour - myWindow
comes on top of the task manager.
However, in Windows 10, that's not the case. The task manager is 'always on top' of other windows, even if those windows in themselves have the 'always on top' style set.
Is there something special that they are doing with the task manager in Windows 10? If yes, is there some work around for bringing my window on top of the task manager? I have tried simply using the BringWindowToTop
function, but that doesn't work. Neither does setWindowPos
with HWND_TOP
as a value for hWndInsertAfter
argument.
Enable or Disable Always On Top for Task Manager using Keyboard Shortcut. 1 Press the Ctrl + Shift + Esc keys to open Task Manager in more details (Alt+D) view. 2 Press the Alt + O keys to open the Options menu, and press the A key to toggle Always on top checked (on) or unchecked (off-default) for what you want.
To make the active window always on top, press Ctrl + Spacebar (or the keyboard shortcut you assigned). Press the keyboard shortcut again to disable “always on top” for the active window. For script options, right-click on the AutoHotkey icon in the system tray.
There were lots of changes made to the Task Manager in Windows 8. It would not be at all surprising that among those changes was special-case code to ensure it was always on top of all other always-on-top windows. Microsoft would not be breaking any contractual guarantees by doing so, since the Task Manager is a built-in part of the operating system. It is free to do as it likes with OS components.
To answer your actual question, there is no documented API for this. WS_EX_TOPMOST
is the best you get. It's meant as an aid for the user, not a way to etch your app's window in their retinas.
When two different windows have this style set, the behavior is implementation-dependent. The only guarantee that you get is windows with the WS_EX_TOPMOST
style are always on top of other windows without this style in the Z order. The system is otherwise free to resolve conflicts as it sees fit, including keeping the most recently-active topmost window on top, breaking the tie by forcing windows belonging to system components to the top, or even punishing processes that have more than one window with this style by forcing their window(s) to the bottom of the "topmost" stack.
Related reading:
From a small research that I did a while ago:
CreateWindowInBand
.ERROR_ACCESS_DENIED
. Perhaps only a signed Microsoft process can use it.A detailed writeup about the functionality was published here:
Window z-order in Windows 10
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With