c#隐藏/显示Windows任务栏
2009-04-16 22:12
411 查看
Windows的任务栏实际上是一个没有标题的窗体,所以只要找到这个窗体,就能隐藏和显示了
[DllImport("user32.dll", EntryPoint = "FindWindowEx", SetLastError = true)] static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow); [DllImport("user32.dll", EntryPoint = "ShowWindow", SetLastError = true)] static extern bool ShowWindow(IntPtr hWnd, uint nCmdShow); private void button1_Click(object sender, EventArgs e) { IntPtr trayHwnd = FindWindowEx(IntPtr.Zero, IntPtr.Zero, "Shell_TrayWnd", null);//在窗口列表中寻找与指定条件相符的第一个子窗口,如果未找到返回0 //IntPtr trayHwnd = FindWindow("Shell_TrayWnd", null);//寻找窗口列表中第一个符合指定条件的顶级窗口,可用api函数GetWindowText取得这个窗口的名称 /*hwnd The handle of the window to change the show status of. nCmdShow Exactly one of the following flags specifying how to show the window: SW_HIDE = 0 Hide the window. SW_MAXIMIZE = 3 Maximize the window. SW_MINIMIZE = 6 Minimize the window. SW_RESTORE = 9 Restore the window (not maximized nor minimized). SW_SHOW = 5 Show the window. SW_SHOWMAXIMIZED = 3 Show the window maximized. SW_SHOWMINIMIZED = 2 Show the window minimized. SW_SHOWMINNOACTIVE = 7 Show the window minimized but do not activate it. SW_SHOWNA = 8 Show the window in its current state but do not activate it. SW_SHOWNOACTIVATE = 4 Show the window in its most recent size and position but do not activate it. SW_SHOWNORMAL = 1 Show the window and activate it (as usual).*/ if (button1.Text == "隐藏") { if (trayHwnd != IntPtr.Zero) { ShowWindow(trayHwnd, 0); button1.Text = "显示"; } } else { ShowWindow(trayHwnd,1); button1.Text = "隐藏"; } }
相关文章推荐
- wince应用程序(实现 获取存储设备的大小、实现 WINCE 系统重新启动、隐藏/显示 Windows 任务栏等等)【C#】
- wince应用程序(实现 获取存储设备的大小、实现 WINCE 系统重新启动、隐藏/显示 Windows 任务栏等等)【C#】
- c#无边框点任务栏图标显示和隐藏
- 教程-隐藏/显示任务栏-程序不在任务显示-全面控制Windows
- C# 控制win7任务栏、开始菜单的显示与隐藏
- C# 实现显示隐藏任务栏
- C# WinForm下,隐藏主窗体,只在进程管理器中显示进程,在任务栏,状态栏都不显示窗体的方法
- 怎样在pb里实现无标题栏 如何使PB窗口总在最上层 显示或隐藏Windows的任务栏
- c#实现隐藏与显示任务栏的方法详解
- 隐藏windows任务栏中的窗口显示
- 隐藏windows任务栏中的窗口显示
- C# Winform 隐藏/显示任务栏
- c#控制系统任务栏的自动隐藏与显示
- c#隐藏显示任务栏,要利用API
- c#控制系统任务栏的自动隐藏与显示
- C#使用Windows API 隐藏/显示 任务栏 (FindWindowEx, ShowWindow)
- 隐藏和显示WINDOWS任务栏
- C#使用Windows API 隐藏/显示 任务栏 (FindWindowEx, ShowWindow)
- C#点击窗体最小化时,隐藏任务栏和显示托盘图标
- c#控制系统任务栏的自动隐藏与显示