到目前为止,我能够使用以下C#代码隐藏
Windows任务栏:
[DllImport("user32.dll")] private static extern int FindWindow(string className,string windowText); [DllImport("user32.dll")] private static extern int ShowWindow(int hwnd,int command); private const int SW_HIDE = 0; private const int SW_SHOW = 1; ... int hwnd = FindWindow("Shell_TrayWnd",""); ShowWindow(hwnd,SW_SHOW);
但是在使用Windows 8时,此代码仅隐藏主监视器上的任务栏,而不是第二个,任务栏也可见.
如何才能在我的窗口显示的屏幕上隐藏任务栏?
解决方法
使用
FindWindowEx.这允许您传入一个窗口以便在Z顺序中搜索.
人机工程学:
DllImport("user32.dll")] private static extern int FindWindowEx(int parent,int afterWindow,string className,string windowText); // Start with the first child,then continue with windows of the same class after it int hWnd = 0; while (hWnd = FindWindowEx(0,hWnd,"Shell_TrayWnd","")) ShowWindow(hWnd,SW_SHOW);
如果您只想在特定屏幕上隐藏任务栏,请使用GetWindowRect并检查窗口所在屏幕的界限,并仅在当前屏幕上的窗口上调用ShowWindow.