1 using System;
2 using System.Linq;
3 using System.Collections.Generic;
4 using System.Text;
5 using System.Windows.Forms;
6 using System.Runtime.InteropServices;
7
8 namespace ContourErrorPreventionPDA
9 {
10 public class FormScreen
11 {
12 const uint SHFS_SHOWTASKBAR = 0x0001;
13 const uint SHFS_HIDETASKBAR = 0x0002;
14 const uint SHFS_SHOWSIPBUTTON = 0x0004;
15 const uint SHFS_HIDESIPBUTTON = 0x0008;
16 const uint SHFS_SHOWSTARTICON = 0x0010;
17 const uint SHFS_HIDESTARTICON = 0x0020;
18 const int SW_HIDE = 0;
19 const int SW_SHOWNORMAL = 1;
20 const int SW_SHOWMINIMIZED = 2;
21 const int SW_SHOWMAXIMIZED = 3;
22 const int SW_SHOWNOACTIVATE = 4;
23 const int SW_RESTORE = 9;
24 const int SW_SHOWDEFAULT = 10;
25
26 [DllImport("aygshell.dll")]
27 private static extern uint SHFullScreen(IntPtr hwndRequester, uint dwState);
28
29 [DllImport("coredll.dll")]
30 private static extern IntPtr GetCapture();
31
32 [DllImport("CoreDll")]
33 private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
34
35 [DllImport("CoreDll")]
36 private static extern bool ShowWindow(IntPtr hwnd, int nCmdShow);
37
38 /// <summary>
39 /// 使程序全屏显示
40 /// </summary>
41 /// <param name="objForm"></param>
42 public static void ShowFullScreen(System.Windows.Forms.Form objForm)
43 {
44 objForm.Capture = true;
45 HideHHTaskBar();
46 IntPtr hwnd = GetCapture();
47 objForm.Capture = false;
48 SHFullScreen(hwnd, SHFS_HIDETASKBAR | SHFS_HIDESIPBUTTON | SHFS_HIDESTARTICON);//全屏化窗口
49 }
50
51 /// <summary>
52 /// 显示任务栏
53 /// </summary>
54 public static void ShowHHTaskBar()
55 {
56 IntPtr lpClassName = FindWindow("HHTaskBar", null);
57 ShowWindow(lpClassName, SW_SHOWNORMAL); //显示任务栏
58 }
59
60 /// <summary>
61 /// 隐藏任务栏
62 /// </summary>
63 public static void HideHHTaskBar()
64 {
65 IntPtr lpClassName = FindWindow("HHTaskBar", null);
66 ShowWindow(lpClassName, SW_HIDE); //隐藏任务栏
67 }
68
69 /// <summary>
70 /// 获取设备的屏幕宽度
71 /// </summary>
72 public static int Width
73 {
74 get
75 {
76 return Screen.PrimaryScreen.Bounds.Width;
77 }
78 }
79 /// <summary>
80 /// 获取设备的屏幕高度
81 /// </summary>
82 public static int Height
83 {
84 get
85 {
86 return Screen.PrimaryScreen.Bounds.Height;
87 }
88 }
89 }
90
91 }