wince 学习笔记2

来源:互联网 发布:玻璃erp软件 编辑:程序博客网 时间:2024/06/08 06:34
   在网上找了一下资料,发现有位前辈写的很不错,自己稍微整理了一下,在wince5.0,wince6.0测试过可以使用。

 

全屏使用示例:

    CScreenLG.ShowFullScreen( "你的窗体");

 

隐藏任务栏:

            CScreenLG.ShowHHTaskBar();

显示任务栏:

            CScreenLG.HideHHTaskBar();

设备的屏幕宽度:

            CScreenLG.Width;

设备的屏幕高度:

            CScreenLG.Height

 

 

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