Win32: How to hide 3rd party windows in taskbar by hWnd
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.
c# remove 3rd party application from taskbar
If you have the handle to the window you can call ShowWindow()
through the Win32 API. Then you can do:
// Let the window disappear (even from taskbar)
ShowWindow(this.Handle, WindowShowStyle.Hide);
// Revive the window back to the user
ShowWindow(this.Handle, WindowShowStyle.ShowNoActivate);
So from now, all your problem is to get the handle of the window you like to hide:
Process[] procs = Process.GetProcesses();
IntPtr hWnd;
foreach(Process proc in procs)
{
if ((hWnd = proc.MainWindowHandle) != IntPtr.Zero)
{
Console.WriteLine("{0} : {1}", proc.ProcessName, hWnd);
}
}
C++ don't display in the taskbar a window created with CreateWindow
set 'dwStyle' to WS_POPUP
, the third argument:
HWND WINAPI CreateWindow(
__in_opt LPCTSTR lpClassName,
__in_opt LPCTSTR lpWindowName,
__in DWORD dwStyle,
__in int x,
__in int y,
__in int nWidth,
__in int nHeight,
__in_opt HWND hWndParent,
__in_opt HMENU hMenu,
__in_opt HINSTANCE hInstance,
__in_opt LPVOID lpParam);
If you're doing win32, I suggest, for your own sanity, you give Qt a try.
Why does WM_CLOSE/DESTROY only partially close my Notepad window?
I'm using [CloseWindow] to try to close the window.
CloseWindow
doesn't close a window -- it minimizes it.
Instead, send the window a WM_CLOSE
message:
SendMessage(h, WM_CLOSE, 0, 0);
Why does the task bar appear when I display a self-drawn modeless dialog? .. sometimes?
Following a long discussion I come to the conclusion that DestroyWindow was not the problem. I found in the end that displaying a dialog.. clicking on the POS, then clicking back on the dialog that sometimes the taskbar would appear. I have spent an entire week trying to find reasons for all of this but to no avail. I thought that assigning the POS window as the owner would solve the problem - it didn't. In the end the solution for my problem was to determine if the taskbar is obscured completely before showing my dialog. If it is, I hide the taskbar for the duration which my dialog is displayed (set its placement to SW_HIDE) and then set it to SW_SHOW when I close my dialog. The task bar doesn't pop up and annoy people anymore. Not a fantastic solution for other peoples' applications perhaps, but perfect for our customers.
Related Topics
How to Create an Array of Pointers
Determining the Alignment of C/C++ Structures in Relation to Its Members
How to Prevent an Object Being Created on the Heap
How to Write a Std::String to a Utf-8 Text File
Why Isn't There an Operator[] for a Std::List
Deprecated Throw-List in C++11
Process Video Stream from Memory Buffer
Mock Non-Virtual Method C++ (Gmock)
Do Static Members of a Class Occupy Memory If No Object of That Class Is Created
How to Cast Simple Pointer to a Multidimensional-Array of Fixed Size
C++ Floating Point to Integer Type Conversions
In C/C++, Is Char* Arrayname[][] a Pointer to a Pointer to a Pointer or a Pointer to a Pointer
How to Execute Another Exe from a C++ Program in Windows
C++11: the Difference Between Memory_Order_Relaxed and Memory_Order_Consume
Why Are '&Array' and 'Array' Pointing to the Same Address
C++ - How to Find the Length of an Integer