c# 设置自动隐藏任务栏、获取状态
2014-01-02 13:51
471 查看
from:
http://stackoverflow.com/questions/1381821/how-to-toggle-switch-windows-taskbar-from-show-to-auto-hide-and-vice-versa
When the code above is implemented just set the Taskbar to autohide by:
Get the current state by:
[/code]
http://stackoverflow.com/questions/1381821/how-to-toggle-switch-windows-taskbar-from-show-to-auto-hide-and-vice-versa
[DllImport("user32.dll", CharSet = CharSet.Auto)] public static extern IntPtr FindWindow(string strClassName, string strWindowName); [DllImport("shell32.dll")] public static extern UInt32 SHAppBarMessage(UInt32 dwMessage, ref APPBARDATA pData); public enum AppBarMessages { New = 0x00000000, Remove = 0x00000001, QueryPos = 0x00000002, SetPos = 0x00000003, GetState = 0x00000004, GetTaskBarPos = 0x00000005, Activate = 0x00000006, GetAutoHideBar = 0x00000007, SetAutoHideBar = 0x00000008, WindowPosChanged = 0x00000009, SetState = 0x0000000a } [StructLayout(LayoutKind.Sequential)] public struct APPBARDATA { public UInt32 cbSize; public IntPtr hWnd; public UInt32 uCallbackMessage; public UInt32 uEdge; public Rectangle rc; public Int32 lParam; } public enum AppBarStates { AutoHide = 0x00000001, AlwaysOnTop = 0x00000002 } /// <summary> /// Set the Taskbar State option /// </summary> /// <param name="option">AppBarState to activate</param> public void SetTaskbarState(AppBarStates option) { APPBARDATA msgData = new APPBARDATA(); msgData.cbSize = (UInt32)Marshal.SizeOf(msgData); msgData.hWnd = FindWindow("System_TrayWnd", null); msgData.lParam = (Int32)(option); SHAppBarMessage((UInt32)AppBarMessages.SetState, ref msgData); } /// <summary> /// Gets the current Taskbar state /// </summary> /// <returns>current Taskbar state</returns> public AppBarStates GetTaskbarState() { APPBARDATA msgData = new APPBARDATA(); msgData.cbSize = (UInt32)Marshal.SizeOf(msgData); msgData.hWnd = FindWindow("System_TrayWnd", null); return (AppBarStates)SHAppBarMessage((UInt32)AppBarMessages.GetState, ref msgData); }
When the code above is implemented just set the Taskbar to autohide by:
SetTaskbarState(AppBarStates.AutoHide);
Get the current state by:
AppBarStates currentState = GetTaskbarState();
[/code]
相关文章推荐
- c#控制系统任务栏的自动隐藏与显示
- wince应用程序(实现 获取存储设备的大小、实现 WINCE 系统重新启动、隐藏/显示 Windows 任务栏等等)【C#】
- 跑马灯状态获取(停止后自动隐藏,用于广告推送等)
- Win10平板模式任务栏怎么设置自动隐藏?
- c#控制系统任务栏的自动隐藏与显示
- win7任务栏自动隐藏怎么设置?
- wince应用程序(实现 获取存储设备的大小、实现 WINCE 系统重新启动、隐藏/显示 Windows 任务栏等等)【C#】
- c#控制系统任务栏的自动隐藏与显示
- office outlook 2010&2013 设置开机自动启动并最小化——隐藏于任务栏通知区域
- Win10任务栏怎么隐藏 详解Win10系统下自动隐藏任务栏设置图文教程
- C# 设置IP地址及设置自动获取IP
- C# 设置程序开机自动运行/设置&获取程序的安装路径
- 判断任务栏是否设置自动隐藏
- [C#]C#如何获取\设置键盘按键状态
- C# 设置程序开机自动运行/设置&获取程序的安装路径
- c#控制系统任务栏的自动隐藏与显示
- C# 设置IP地址及设置自动获取IP
- magento shell 脚本 通过api获取paypal的订单状态,同步到magento网站的订单,自动纠正不准确的订单状态
- [转]使用C#获取WinCE系统中的内存状态及系统状态
- 在vb中使用Iphlpapi.dll获取网络信息 第二章 第十七节 设置TCP连接状态