簡體   English   中英

使用WinAPI隱藏C#中任務欄的窗口

[英]Hiding window from taskbar in C# with WinAPI

相信我,我用谷歌搜索它並期望它是一個相當容易的發現 - 事實證明它不是。 我有窗把手,但沒有窗體。 我該怎么做? 謝謝!

聲明這些:

 [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;

然后在顯示表單之前使用它:


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

(將句柄更改為存儲窗口句柄的任何內容)

將Form的ShowInTaskbar屬性設置為false。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM