Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove window from taskbar on 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":

enter image description here

like image 783
Unick Avatar asked Jun 10 '16 12:06

Unick


Video Answer


2 Answers

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.

like image 55
Cody Gray Avatar answered Sep 19 '22 07:09

Cody Gray


TL;DR:

  1. Remove both WS_EX_APPWINDOW and WS_EX_TOOLWINDOW from the extended style.
  2. Set an owner for the window.

Example:

Removing flags from the extended style:

SetWindowLong(myHWND, GWL_EXSTYLE, 
    GetWindowLong(myHWND, GWL_EXSTYLE) & ~WS_EX_APPWINDOW & ~WS_EX_TOOLWINDOW);

Setting an owner:

SetWindowLongPtr(myHWND, GWLP_HWNDPARENT, myOwnerHWND);

Full explanation:

Despite Cody's answer being great, it does not quite answer the exact question.

The exact question is: "How to display a window that does not appear in the taskbar, yet appears only on one virtual desktop?

As Cody explained, there are several ways to remove the taskbar button for a window. However, there is only one way among them that makes it display on only one virtual desktop at the same time.

If you include the flag WS_EX_APPWINDOW in your extended style, it will force the window to show in the taskbar. That's why it must be cleared in this case.

If you include the flag WS_EX_TOOLWINDOW in your extended style, it will force the window not to show in the taskbar, but will force the window to be shown on all virtual desktops. Thus it's not an option either here.

Finally, if your window has neither flags, it will show in the taskbar if and only if it does not have an owner. Either way, it will not force itself on all virtual desktops. Hence, the solution is to have neither flags but to set an owner.

like image 23
fkorsa Avatar answered Sep 22 '22 07:09

fkorsa