Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Task Manager a special kind of 'Always on Top' window for windows 10?

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.

like image 940
TheBlueNotebook Avatar asked Aug 31 '16 10:08

TheBlueNotebook


People also ask

Is Task Manager always on top?

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.

Can you make a window always stay on top Windows 10?

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.


2 Answers

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:

  • What if two programs did this?
  • What if two programs did this? Practical exam
  • How do I create a topmost window that is never covered by other topmost windows?
like image 197
Cody Gray Avatar answered Oct 19 '22 14:10

Cody Gray


From a small research that I did a while ago:

  • The Task Manager is indeed a "special kind" of Always-on-Top.
  • The Task Manager window is being created with the following undocumented function: CreateWindowInBand.
  • Trying to use this function from another process results in ERROR_ACCESS_DENIED. Perhaps only a signed Microsoft process can use it.

2020 update:

A detailed writeup about the functionality was published here:
Window z-order in Windows 10

like image 43
Paul Avatar answered Oct 19 '22 13:10

Paul