How to create a window on the taskbar?

The window does not appear on the taskbar only in the system tray. How can I make it also appear in the taskbar?

I tried the following code, but this did not affect:

int windowStyle = GetWindowLong(pMainWindow, GWL_EXSTYLE);
SetWindowLong(pMainWindow, GWL_EXSTYLE, windowStyle & WS_EX_TOOLWINDOW);

And this is NOT my form! I get the handle from Process.GetProcessesByName, and I don't know how to access the properties of the Form class:

Process[] processes = Process.GetProcessesByName("somename");
someProcess = processes[0];

pMainWindow = someProcess.MainWindowHandle;
+3
source share
4 answers

The following seems to do the trick. If you hide and retell the window after calling SetWindowLong, it appears in the taskbar.

I am trying to find a way to remove it from the taskbar when the window is minimized ...

[DllImport("User32.Dll")]                
public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);

[DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);

private const int SW_HIDE = 0x00;
private const int SW_SHOW = 0x05;

private const int WS_EX_APPWINDOW = 0x40000;
private const int GWL_EXSTYLE = -0x14;

private void ShowWindowInTaskbar(IntPtr pMainWindow)
{                       
    SetWindowLong(pMainWindow, GWL_EXSTYLE, WS_EX_APPWINDOW);

    ShowWindow(pMainWindow, SW_HIDE);
    ShowWindow(pMainWindow, SW_SHOW);      
}
+2
source

WS_EX_APPWINDOW WS_EX_TOOLWINDOW. :

WS_EX_APPWINDOW: , .

WS_EX_TOOLWINDOW:... , , ALT + TAB...

+2

Set the .ShowInTaskbar property of the form to true.

0
source

Is it possible to return a Process.GetProcessesByName () object as a form, and then set its .ShowInTaskbar property?

-1
source

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


All Articles