从 Windows 10 的任务栏中删除窗口
我想在具有多个桌面的 Windows 10 上从任务栏中删除窗口.对于 Windows 8.1,我使用了 ITaskbarList::DeleteTab,效果很好.
I want to remove window from taskbar on Windows 10 with multiple desktops. For Windows 8.1 i used ITaskbarList::DeleteTab and it works excellent.
对于 Windows 10,此方法也会从任务栏中隐藏 Windows,但之后我会在所有桌面上看到此窗口.我只想在一个桌面上看到这个窗口.
For Windows 10 this method hides Windows from taskbar too, but after it i see this window on all desktops. I want to see this window only on one desktop.
有谁知道在 Windows 10 中从任务栏中隐藏窗口并将此窗口保留在一个桌面上的方法?
Does anyone know the method to hide window from task bar in Windows 10 and stay this window on one desktop?
您可以在下面看到,我在从 Windows 10 的任务栏中隐藏窗口"下的意思:
Below you can see, what i meant under "hide window from task bar in Windows 10":
推荐答案
在我的理解中,通过我的经验测试证明,任务栏预览中出现的窗口与任务栏中通常出现的窗口完全相同.很久以前,比如说在 Windows 2000 中,应用程序的每个符合条件的窗口都只会在任务栏上显示为按钮.从 Windows XP 开始,任务栏分组成为一种选择,因此来自单个应用程序的所有符合条件的窗口都可以组合在一起,并在任务栏上显示为单个按钮.然后,在 Windows Vista 中,当您将鼠标悬停在相应的任务栏按钮上时,可以显示这些打开窗口的预览.Windows 8 和 Windows 10 都没有改变这一基本规则.他们只是改变了预览的外观.
In my understanding, borne out by my empirical tests, the windows that appear in the taskbar previews are exactly the same windows that would ordinarily appear in the taskbar. A long time ago, say in Windows 2000, each of an application's eligible windows would just appear as buttons on the taskbar. Starting in Windows XP, taskbar grouping became an option, so that all eligible windows from a single application could be grouped together and appear as a single button on the taskbar. Then, in Windows Vista, it became possible to display previews of these open windows when you hovered over the corresponding taskbar button. Neither Windows 8 nor Windows 10 changed that fundamental rule; they only changed the appearance of the previews.
因此,我们可以参考 MSDN 文档 关于哪些窗口出现在任务栏上的规则:
As such, we can refer back to the MSDN documentation for the rules about which windows appear on the taskbar:
每当应用程序创建一个不属于自己的窗口时,Shell 就会在任务栏上创建一个按钮.要确保窗口按钮位于任务栏上,请使用 WS_EX_APPWINDOW
扩展样式创建一个无主窗口.要防止窗口按钮被放置在任务栏上,请使用 WS_EX_TOOLWINDOW
扩展样式创建无主窗口.作为替代方案,您可以创建一个隐藏窗口,并让这个隐藏窗口成为您可见窗口的所有者.
The Shell creates a button on the taskbar whenever an application creates a window that isn't owned. To ensure that the window button is placed on the taskbar, create an unowned window with the
WS_EX_APPWINDOW
extended style. To prevent the window button from being placed on the taskbar, create the unowned window with theWS_EX_TOOLWINDOW
extended style. As an alternative, you can create a hidden window and make this hidden window the owner of your visible window.
Raymond Chen 更准确地总结了这些规则这里.引用他的话:
Raymond Chen has summarized these rules more precisely here. Quoting him:
有一些关于哪些窗口进入任务栏的基本规则.简而言之:
There are some basic rules on which windows go into the taskbar. In short:
- 如果设置了
WS_EX_APPWINDOW
扩展样式,那么它将显示(当可见时). - 如果窗口是顶层无主窗口,那么它将显示(可见时).
- 否则不显示.
- If the
WS_EX_APPWINDOW
extended style is set, then it will show (when visible). - If the window is a top-level unowned window, then it will show (when visible).
- Otherwise it doesn't show.
(虽然 ITaskbarList 界面混淆了这一点上升一点.)
(Though the ITaskbarList interface muddies this up a bit.)
你之前把它弄混了,调用 ITaskbarList::DeleteTab
.那是没有必要的.为确保窗口不会出现在任务栏中,只需应用与窗口确实出现在任务栏中的规则相反的规则.
You were muddying it up before, calling ITaskbarList::DeleteTab
. That is not necessary. To ensure that a window does not appear in the taskbar, just apply the converse of the rules governing when a window does appear in the taskbar.
如果您有一个顶层无主窗口,它将显示在任务栏中,除非您删除 WS_EX_APPWINDOW
扩展窗口样式.如果您有一个拥有的窗口,那么它将不会显示在任务栏中,除非将 WS_EX_APPWINDOW
扩展窗口样式设置为强制它在那里.
If you have a top-level unowned window, it will be shown in the taskbar unless you remove the WS_EX_APPWINDOW
extended window style. If you have an owned window, then it will not be shown in the taskbar unless the WS_EX_APPWINDOW
extended window style is set to force it there.
因此,如果您设置了 WS_EX_APPWINDOW
扩展窗口样式集,则应将其删除.那就是强制窗口显示在任务栏中.
So if you have the WS_EX_APPWINDOW
extended window style set, you should remove it. That is forcing the window to be displayed in the taskbar.
否则,您应该为您的窗口设置所有者.例如,使第二个窗口归第一个窗口所有.
Otherwise, you should set an owner for your window. For example, make the second window be owned by the first.
相关文章