[英]Hide Taskbar in Windows 8
到目前為止,我能夠使用以下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時,此代碼僅隱藏主監視器上的任務欄,而不是第二個,任務欄也可見。
如何才能在我的窗口顯示的屏幕上隱藏任務欄?
不要隱藏任務欄; 做這樣的事情是錯誤的。 相反,只需創建一個全屏窗口,任務欄足夠聰明,可以讓您自己走開。
您可以在他的博客上閱讀微軟的Raymond Chen的一個很好的解釋和評論。
利用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。
我遇到了同樣的問題。
1)在多個監視器上運行應用程序
2)在第一台顯示器上沒有問題,應用程序保持在最頂層
3)但如果單擊第二個窗口,則會出現任務欄,反之亦然
使用FindWindowEx,只找到一個Shell_TrayWnd。 它是第一個屏幕中的一個,可以隱藏
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.