一个窗口不显示在任务栏中,只在系统托盘中。我怎样才能让它显示在任务栏中呢?
我尝试以下code,但它没有任何效果:
INT windowStyle = GetWindowLong(pMainWindow,GWL_EXSTYLE);
SetWindowLong函数(pMainWindow,GWL_EXSTYLE,windowStyle和放大器; WS_EX_TOOLWINDOW);
和,这不是我的形式!我碰到Process.GetProcessesByName手柄,我不知道如何访问Form类的属性:
过程[] =过程Process.GetProcessesByName(somename);
someProcess =流程[0];
pMainWindow = someProcess.MainWindowHandle;
解决方案
下面似乎做的伎俩。如果隐藏&功放; SetWindowLong函数调用它,然后显示在任务栏后重新出现。该窗口。
我在努力寻找一种方法来从任务栏中移除它曾经窗口是最小化...
[的DllImport(user32.dll中)
公共静态外部INT的SetWindowLong(IntPtr的的HWND,国际nIndex,INT dwNewLong);
[的DllImport(user32.dll中)
静态外部布尔的ShowWindow(IntPtr的的HWND,INT的nCmdShow);
私人const int的SW_HIDE = 0×00;
私人const int的SW_SHOW = 0×05;
私人const int的WS_EX_APPWINDOW = 0x40000;
私人const int的GWL_EXSTYLE = -0x14;
私人无效ShowWindowInTaskbar(IntPtr的pMainWindow)
{
SetWindowLong函数(pMainWindow,GWL_EXSTYLE,WS_EX_APPWINDOW);
的ShowWindow(pMainWindow,SW_HIDE);
的ShowWindow(pMainWindow,SW_SHOW);
}
A window is not showing in the task bar, only in the system tray. How can I make it show up in the taskbar as well?
I tried the following code, but it had no effect:
int windowStyle = GetWindowLong(pMainWindow, GWL_EXSTYLE);
SetWindowLong(pMainWindow, GWL_EXSTYLE, windowStyle & WS_EX_TOOLWINDOW);
And, this is NOT my form! I'm getting the handle from Process.GetProcessesByName and I don't know how to access properties of the Form class:
Process[] processes = Process.GetProcessesByName("somename");
someProcess = processes[0];
pMainWindow = someProcess.MainWindowHandle;
解决方案
The following seems to do the trick. If you hide & reshow the window after calling SetWindowLong it then shows in the taskbar.
I'm struggling to find a way to remove it from the taskbar once 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);
}