Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Win32: How to hide 3rd party windows in taskbar by hWnd

I have to hide popup windows in third party library.

I have implemented windows hook stuff with SetWindowsHookEx and know all the newely created hWnd(s). I listen to HSHELL_WINDOWCREATED callback and do the following:

long style= GetWindowLong(hWnd, GWL_STYLE);
style &= ~(WS_VISIBLE);    // this works - window become invisible 

style |= WS_EX_TOOLWINDOW;   // flags don't work - windows remains in taskbar
style &= ~(WS_EX_APPWINDOW); 

SetWindowLong(hWnd, GWL_STYLE, style);      

What I do wrong here to hide newely created windows in task bar?

like image 307
Andrew Florko Avatar asked Aug 28 '11 04:08

Andrew Florko


People also ask

How do I hide a window on my Taskbar?

Right click the taskbar and choose "Properties". In the menu that opens, click the option that says "Auto-hide the taskbar". This will cause the taskbar to disappear until you mouse over where it is on the screen.

How do I hide Windows apps from Taskbar?

Right-click on your taskbar > Taskbar settings. Under the Notification area, click "Select which icons appear on the taskbar" then disable the app you're looking for.


1 Answers

Before you use SetWindowLong, call ShowWindow(hWnd, SW_HIDE), then call SetWindowLong, then call ShowWindow again like ShowWindow(hWnd, SW_SHOW). So your code will look like this:

long style= GetWindowLong(hWnd, GWL_STYLE);
style &= ~(WS_VISIBLE);    // this works - window become invisible 

style |= WS_EX_TOOLWINDOW;   // flags don't work - windows remains in taskbar
style &= ~(WS_EX_APPWINDOW); 

ShowWindow(hWnd, SW_HIDE); // hide the window
SetWindowLong(hWnd, GWL_STYLE, style); // set the style
ShowWindow(hWnd, SW_SHOW); // show the window for the new style to come into effect
ShowWindow(hWnd, SW_HIDE); // hide the window so we can't see it

Here is a relevant quote from Microsoft's Website:

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.

The Shell will remove a window's button from the taskbar only if the window's style supports visible taskbar buttons. If you want to dynamically change a window's style to one that doesn't support visible taskbar buttons, you must hide the window first (by calling ShowWindow with SW_HIDE), change the window style, and then show the window.

like image 124
Seth Carnegie Avatar answered Sep 28 '22 10:09

Seth Carnegie