Hiding a window from the taskbar in C # using WinAPI

Believe me, I have Googled and expected it to be quite easy to find - it turns out that it is not. I have a window handle but no shape. How should I do it? Thank!

+3
source share
2 answers

Declare the following:

 [DllImport("user32.dll", SetLastError = true)]
static extern int GetWindowLong(IntPtr hWnd, int nIndex);
[DllImport("user32.dll")]
static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
private const int GWL_EX_STYLE = -20;
private const int WS_EX_APPWINDOW = 0x00040000, WS_EX_TOOLWINDOW = 0x00000080;

And then use this before the form is shown:


SetWindowLong(handle, GWL_EX_STYLE, (GetWindowLong(handle, GWL_EX_STYLE) | WS_EX_TOOLWINDOW) & ~WS_EX_APPWINDOW);

(change the handle to everything that is stored in your window handle)

+5
source

Set the ShowInTaskbar property to false.

+2
source

Source: https://habr.com/ru/post/1754906/


All Articles