在网上找了一下资料,发现有位前辈写的很不错,自己稍微整理了一下,在wince5.0,wince6.0测试过可以使用。
全屏使用示例:
CScreenLG.ShowFullScreen( "你的窗体");
隐藏任务栏:
CScreenLG.ShowHHTaskBar();
显示任务栏:
CScreenLG.HideHHTaskBar();
设备的屏幕宽度:
CScreenLG.Width;
设备的屏幕高度:
CScreenLG.Height
public class CScreenLG { const uint SHFS_SHOWTASKBAR = 0x0001; const uint SHFS_HIDETASKBAR = 0x0002; const uint SHFS_SHOWSIPBUTTON = 0x0004; const uint SHFS_HIDESIPBUTTON = 0x0008; const uint SHFS_SHOWSTARTICON = 0x0010; const uint SHFS_HIDESTARTICON = 0x0020; const int SW_HIDE = 0; const int SW_SHOWNORMAL = 1; const int SW_SHOWMINIMIZED = 2; const int SW_SHOWMAXIMIZED = 3; const int SW_SHOWNOACTIVATE = 4; const int SW_RESTORE = 9; const int SW_SHOWDEFAULT = 10; [DllImport("aygshell.dll")] private static extern uint SHFullScreen(IntPtr hwndRequester, uint dwState); [DllImport("coredll.dll")] private static extern IntPtr GetCapture(); [DllImport("CoreDll")] private static extern IntPtr FindWindow(string lpClassName, string lpWindowName); [DllImport("CoreDll")] private static extern bool ShowWindow(IntPtr hwnd, int nCmdShow); /// <summary> /// 使程序全屏显示 /// </summary> /// <param name="objForm"></param> public static void ShowFullScreen(System.Windows.Forms.Form objForm) { objForm.Capture = true; HideHHTaskBar(); IntPtr hwnd = GetCapture(); objForm.Capture = false; SHFullScreen(hwnd, SHFS_HIDETASKBAR | SHFS_HIDESIPBUTTON | SHFS_HIDESTARTICON);//全屏化窗口 } /// <summary> /// 显示任务栏 /// </summary> public static void ShowHHTaskBar() { IntPtr lpClassName = FindWindow("HHTaskBar", null); ShowWindow(lpClassName, SW_SHOWNORMAL); //显示任务栏 } /// <summary> /// 隐藏任务栏 /// </summary> public static void HideHHTaskBar() { IntPtr lpClassName = FindWindow("HHTaskBar", null); ShowWindow(lpClassName, SW_HIDE); //隐藏任务栏 } /// <summary> /// 获取设备的屏幕宽度 /// </summary> public static int Width{ get{ return Screen.PrimaryScreen.Bounds.Width; } } /// <summary> /// 获取设备的屏幕高度 /// </summary> public static int Height{ get{ return Screen.PrimaryScreen.Bounds.Height; } } }
转载 http://blog.youkuaiyun.com/zh2305/archive/2008/08/28/2844169.aspx