手机
当前位置:查字典教程网 >编程开发 >C#教程 >c#实现隐藏与显示任务栏的方法详解
c#实现隐藏与显示任务栏的方法详解
摘要:1.导入System.Runtime.InteropServices命名空间。2.API函数ShowWindow()能够控制人和窗体的现实状...

1.导入System.Runtime.InteropServices命名空间。

2.API函数ShowWindow()能够控制人和窗体的现实状态,其声明格式如下:

复制代码 代码如下:

[DllImport("user32.dll")]

public static extern int ShowWindow(int hwnd,int nCmdShow);

其中hwnd表示窗体的句柄,nCmdShow表示窗体的现实状态。

3.API函数FindWindow()可用于返回任务栏所在窗体类“Shell_TrayWnd”句柄,其声明格式如下:

复制代码 代码如下:

[DllImport("user32.dll")]

public static extern int FindWindow(string lpClassName,string lpWindowName);

实例如下,主要代码为(使用了2个btn控件):

复制代码 代码如下:

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

}

【c#实现隐藏与显示任务栏的方法详解】相关文章:

c#调用存储过程实现登录界面详解

C#中实现任意List的全组合算法代码

深入分析WPF客户端读取高清图片卡以及缩略图的解决方法详解

使用c#在word文档中创建表格的方法详解

深入C# 内存管理以及优化的方法详解

C# 设置系统日期格式的方法

深入C#任务管理器中应用程序选项隐藏程序本身的方法详解

C#实现窗体淡入淡出效果的方法总结

用C#缩小照片上传到各种空间的具体方法

c#中抽象类和接口的详细介绍

精品推荐
分类导航