任务管理器是 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.
为了测试此功能,我打开任务管理器窗口 - 将其设置为始终在顶部,然后打开我的窗口 (myWindow
).
To test this feature, I open the task manager window - set it to always on top and then I open my window (myWindow
).
在 Windows 7 中,我观察到预期的行为 - myWindow
位于任务管理器之上.
In Windows 7, I observe the expected behaviour - myWindow
comes on top of the task manager.
但是,在 Windows 10 中,情况并非如此.任务管理器始终位于"其他窗口的顶部,即使这些窗口本身设置了始终位于顶部"样式.
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.
他们在 Windows 10 中使用任务管理器有什么特别之处吗?如果是,是否有一些解决方法可以将我的窗口置于任务管理器之上?我试过简单地使用 BringWindowToTop
函数,但这不起作用.setWindowPos
也不使用 HWND_TOP
作为 hWndInsertAfter
参数的值.
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.
推荐答案
在 Windows 8 中对任务管理器进行了很多更改.在这些更改中,有一些特殊情况的代码来确保它,这并不奇怪.始终位于所有其他始终位于顶部的窗口之上.微软这样做不会违反任何合同保证,因为任务管理器是操作系统的内置部分.操作系统组件可以随心所欲.
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.
要回答您的实际问题,对此没有记录的 API.WS_EX_TOPMOST
是最好的.这是为了帮助用户,而不是在他们的视网膜上蚀刻您的应用窗口.
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.
当两个不同的窗口设置了这种样式时,行为是依赖于实现的.您获得的唯一保证是具有 WS_EX_TOPMOST
样式的窗口在 Z 顺序中始终位于其他 没有此样式的窗口之上.系统可以自由地解决它认为合适的冲突,包括将最近活动的最顶层窗口保持在顶部,通过强制属于系统组件的窗口到顶部来打破平局,甚至惩罚具有多个窗口的进程这种风格是通过强制他们的窗口到最顶层"的底部来实现的.堆栈.
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.
相关阅读:
- 如果两个程序这样做会怎样?
- 如果两个程序这样做会怎样?实践考试
- 如何创建一个永远不会被其他最顶层窗口覆盖的最顶层窗口窗户?
相关文章