您的位置:首页 > 编程语言 > C#

C#显示与隐藏系统任务栏和开始菜单栏

2014-09-18 17:08 429 查看
private const int SW_HIDE = 0;
private const int SW_SHOW = 5;

[DllImportAttribute("user32.dll")]
private static extern int FindWindow(string ClassName,string WindowName);
[DllImport("user32.dll")]
private static extern int ShowWindow(int handle,int cmdShow);

//显示
private void button3_Click(object sender, EventArgs e)
{
ShowWindow(FindWindow("Shell_TrayWnd", null), SW_SHOW);
ShowWindow(FindWindow("Button", null), SW_SHOW);
}
//全屏
private void button2_Click(object sender, EventArgs e)
{
ShowWindow(FindWindow("Shell_TrayWnd", null), SW_HIDE);
ShowWindow(FindWindow("Button", null), SW_HIDE);
}


说明:

(1)引用了系统API函数,需要引用命名空间

using System.Runtime.InteropServices;

(2)ShowWindow()参数类型是一些int类型,可以查看MDNS

也可以写成
ShowWindow(FindWindow("Shell_TrayWnd", null), 0);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: