c#實(shí)現(xiàn)隱藏與顯示任務(wù)欄的方法詳解
1.導(dǎo)入System.Runtime.InteropServices命名空間。
2.API函數(shù)ShowWindow()能夠控制人和窗體的現(xiàn)實(shí)狀態(tài),其聲明格式如下:
[DllImport("user32.dll")]
public static extern int ShowWindow(int hwnd,int nCmdShow);
其中hwnd表示窗體的句柄,nCmdShow表示窗體的現(xiàn)實(shí)狀態(tài)。
3.API函數(shù)FindWindow()可用于返回任務(wù)欄所在窗體類“Shell_TrayWnd”句柄,其聲明格式如下:
[DllImport("user32.dll")]
public static extern int FindWindow(string lpClassName,string lpWindowName);
實(shí)例如下,主要代碼為(使用了2個(gè)btn控件):
private const int SW_HIDE = 0; //隱藏任務(wù)欄
private const int SW_RESTORE = 9;//顯示任務(wù)欄
[DllImport("user32.dll")]
public static extern int ShowWindow(int hwnd,int nCmdShow);
[DllImport("user32.dll")]
public static extern int FindWindow(string lpClassName,string lpWindowName);
private void button1_Click(object sender, EventArgs e)
{
ShowWindow(FindWindow("Shell_TrayWnd",null),SW_HIDE);
//YinYiNiao's Blog
}
private void button2_Click(object sender, EventArgs e)
{
ShowWindow(FindWindow("Shell_TrayWnd",null),SW_RESTORE);
}
- 用 C# 編寫一個(gè)停放在任務(wù)欄上的圖標(biāo)程序
- 解決C# 截取當(dāng)前程序窗口指定位置截圖的實(shí)現(xiàn)方法
- 解決C#獲取鼠標(biāo)相對(duì)當(dāng)前窗口坐標(biāo)的實(shí)現(xiàn)方法
- C# WinForm中禁止改變窗口大小的方法
- C# Winform中實(shí)現(xiàn)主窗口打開登錄窗口關(guān)閉的方法
- C#設(shè)置窗體最大化且不遮擋任務(wù)欄的方法
- C#隱式運(yùn)行CMD命令(隱藏命令窗口)
- C#窗口實(shí)現(xiàn)單例模式的方法
- C#實(shí)現(xiàn)簡(jiǎn)單的Login窗口實(shí)例
- C#獲取任務(wù)欄顯示進(jìn)程的方法
- C#調(diào)用dos窗口獲取相關(guān)信息的方法
- C#實(shí)現(xiàn)將程序鎖定到Win7任務(wù)欄的方法
- C#實(shí)現(xiàn)任務(wù)欄通知窗口
相關(guān)文章
C#并行編程之?dāng)?shù)據(jù)并行Tasks.Parallel類
這篇文章介紹了C#并行編程之?dāng)?shù)據(jù)并行Tasks.Parallel類,文中通過(guò)示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2022-05-05C# 實(shí)現(xiàn)特殊字符快速轉(zhuǎn)碼
這篇文章主要介紹了C# 實(shí)現(xiàn)特殊字符快速轉(zhuǎn)碼,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2021-01-01C# Form自定義光標(biāo)的簡(jiǎn)單實(shí)現(xiàn)
這篇文章主要介紹了C# Form自定義光標(biāo)的簡(jiǎn)單實(shí)現(xiàn),有需要的朋友可以參考一下2014-01-01C# DataTable 轉(zhuǎn)換為 實(shí)體類對(duì)象實(shí)例
如果你的實(shí)體類與數(shù)據(jù)庫(kù)表是完全一致的。上代碼:2013-04-04Unity shader實(shí)現(xiàn)移動(dòng)端模擬深度水效果
這篇文章主要為大家詳細(xì)介紹了Unity shader實(shí)現(xiàn)移動(dòng)端模擬深度水效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-05-05