从Windows 10上的任务栏中删除窗口(Remove window from taskbar on Windows 10)

编程入门 行业动态 更新时间:2024-10-28 18:23:08
从Windows 10上的任务栏中删除窗口(Remove window from taskbar on Windows 10)

我想从具有多个桌面的Windows 10上的任务栏中删除窗口。 对于Windows 8.1,我使用了ITaskbarList :: DeleteTab,它运行良好。

对于Windows 10,此方法也会将Windows从任务栏中隐藏,但在此之后我会在所有桌面上看到此窗口。 我想只在一个桌面上看到这个窗口。

有没有人知道在Windows 10中从任务栏隐藏窗口的方法并将此窗口保留在一个桌面上?

下面你可以看到,我在“从Windows 10中的任务栏隐藏窗口”中的含义:

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.

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.

Does anyone know the method to hide window from task bar in Windows 10 and stay this window on one desktop?

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都没有改变这一基本规则; 他们只改变了预览的外观。

因此,我们可以参考MSDN文档 ,了解有关哪些窗口出现在任务栏上的规则:

只要应用程序创建了一个不属于的窗口,Shell就会在任务栏上创建一个按钮。 要确保窗口按钮位于任务栏上,请使用WS_EX_APPWINDOW扩展样式创建无主窗口。 要防止窗口按钮放在任务栏上,请使用WS_EX_TOOLWINDOW扩展样式创建无主窗口。 作为替代方案,您可以创建隐藏窗口并使此隐藏窗口成为可见窗口的所有者。

Raymond Chen 在这里更准确地总结了这些规则。 引用他:

窗口进入任务栏有一些基本规则。 简而言之:

如果设置了WS_EX_APPWINDOW扩展样式,那么它将显示(当可见时)。 如果窗口是顶级无主窗口,则它将显示(当可见时)。 否则它没有显示。

(虽然ITaskbarList界面让人觉得有点混乱。)

你之前搞砸了,调用ITaskbarList::DeleteTab 。 这不是必要的。 要确保窗口不会出现在任务栏中,只需应用控制任务栏中窗口显示的规则的相反操作。

如果您有一个顶级无主窗口,除非您删除 WS_EX_APPWINDOW扩展窗口样式,否则它将显示在任务栏中。 如果您拥有一个拥有的窗口,那么除非将WS_EX_APPWINDOW扩展窗口样式设置为强制它,否则它将不会显示在任务栏中。

因此,如果您设置了WS_EX_APPWINDOW扩展窗口样式,则应将其删除。 这就是强制窗口显示在任务栏中。

否则,您应该为您的窗口设置所有者。 例如,使第二个窗口由第一个窗口拥有。

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.

As such, we can refer back to the MSDN documentation for the rules about which windows appear on the taskbar:

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 the WS_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 has summarized these rules more precisely here. Quoting him:

There are some basic rules on which windows go into the taskbar. In short:

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.

(Though the ITaskbarList interface muddies this up a bit.)

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.

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.

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.

更多推荐

本文发布于:2023-08-03 07:54:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1386114.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:栏中   窗口   Windows   window   Remove

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!