问题描述
我正在寻找一种方法来拦截 ShowDesktop 事件并将我的窗口设置在前面.有没有办法在不使用 API 钩子的情况下做到这一点?谢谢,奥马尔.
I'm looking for a way to intercept the ShowDesktop event and set my window at front.Is there a way doing it without using API hooks?Thanks,Omer.
推荐答案
如果您正在编写 Windows 任务栏样式的 Dock,那么只需确保您的窗口设置了 WS_EX_TOPMOST
并且显示桌面"将离开单独它.或者使用 SetWindowPos
使其成为创建后的最顶层窗口,例如:
If you're writing a Windows taskbar style dock then simply make sure your window has WS_EX_TOPMOST
set and 'Show Desktop' will leave it alone. Alternatively use SetWindowPos
to make it the top-most window after it has been created, e.g.:
SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
更新:您需要使用 Windows 应用程序栏 API 来制作停靠"样式的应用程序.请参阅此处了解更多详情.
Update: You need to use the Windows Application Bar API to make a 'dock' style app. See here for more details.
应用程序栏也需要从Alt+Tab等显示的顶级列表中删除,可以通过添加WS_EX_TOOLWINDOW
并删除WS_EX_APPWINDOW
来完成.
Application bars also need to be removed from the top-level list displayed when you Alt+Tab etc, which can be done by adding the WS_EX_TOOLWINDOW
and removing WS_EX_APPWINDOW
.
我应该早点说清楚,抱歉.
I should of made this clear earlier, apologies.
这篇关于如何拦截“显示桌面"事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!