源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

c#实现隐藏与显示任务栏的方法详解

  • 时间:2020-01-15 21:07 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:c#实现隐藏与显示任务栏的方法详解
[b]1.导入System.Runtime.InteropServices命名空间。[/b] [b]2.API函数ShowWindow()能够控制人和窗体的现实状态,其声明格式如下: [/b]
[u]复制代码[/u] 代码如下:
[DllImport("user32.dll")] public static extern int ShowWindow(int hwnd,int nCmdShow);
其中hwnd表示窗体的句柄,nCmdShow表示窗体的现实状态。 [b]3.API函数FindWindow()可用于返回任务栏所在窗体类“Shell_TrayWnd”句柄,其声明格式如下:[/b]
[u]复制代码[/u] 代码如下:
[DllImport("user32.dll")] public static extern int FindWindow(string lpClassName,string lpWindowName);
实例如下,主要代码为(使用了2个btn控件):
[u]复制代码[/u] 代码如下:
 private const int SW_HIDE = 0;  //隐藏任务栏         private const int SW_RESTORE = 9;//显示任务栏         [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);         }
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部