WinCE全屏

namespace TaskBarHide
2 {
3 public partial class MainForm : Form
4 {
5 public MainForm()
6 {
7 InitializeComponent();
8 }
9
10 private void btnShow_Click( object sender, EventArgs e)
11 {
12 Rectangle rect = new Rectangle();
13 FullScreenClass.SetFullScreen( true , ref rect); // 显示
14 btnShow.Enabled = false ;
15 btnHide.Enabled = true ;
16 }
17
18 private void btnHide_Click( object sender, EventArgs e)
19 {
20 Rectangle rect = new Rectangle();
21 FullScreenClass.SetFullScreen( false , ref rect); // 隐藏
22 btnShow.Enabled = true ;
23 btnHide.Enabled = false ;
24 }
25 }
26
27 public class FullScreenClass
28 {
29 public const int SPI_SETWORKAREA = 47 ;
30 public const int SPI_GETWORKAREA = 48 ;
31 public const int SW_HIDE = 0x00 ;
32 public const int SW_SHOW = 0x0001 ;
33 public const int SPIF_UPDATEINIFILE = 0x01 ;
34 [DllImport( " coredll.dll " , EntryPoint = " FindWindow " )]
35 private static extern IntPtr FindWindow( string lpWindowName, string lpClassName);
36 [DllImport( " coredll.dll " , EntryPoint = " ShowWindow " )]
37 private static extern bool ShowWindow(IntPtr hwnd, int nCmdShow);
38 [DllImport( " coredll.dll " , EntryPoint = " SystemParametersInfo " )]
39 private static extern int SystemParametersInfo( int uAction, int uParam, ref Rectangle lpvParam, int fuWinIni);
40
41 /// <summary>
42 /// 设置全屏或取消全屏
43 /// </summary>
44 /// <param name="fullscreen"> true:全屏 false:恢复 </param>
45 /// <param name="rectOld"> 设置的时候,此参数返回原始尺寸,恢复时用此参数设置恢复 </param>
46 /// <returns> 设置结果 </returns>
47 public static bool SetFullScreen( bool fullscreen, ref Rectangle rectOld)
48 {
49 IntPtr Hwnd = FindWindow( " HHTaskBar " , null );
50 if (Hwnd == IntPtr.Zero) return false ;
51 if (fullscreen)
52 {
53 ShowWindow(Hwnd, SW_HIDE);
54 Rectangle rectFull = Screen.PrimaryScreen.Bounds;
55 SystemParametersInfo(SPI_GETWORKAREA, 0 , ref rectOld, SPIF_UPDATEINIFILE); // get
56 SystemParametersInfo(SPI_SETWORKAREA, 0 , ref rectFull, SPIF_UPDATEINIFILE); // set
57 }
58 else
59 {
60 ShowWindow(Hwnd, SW_SHOW);
61 SystemParametersInfo(SPI_SETWORKAREA, 0 , ref rectOld, SPIF_UPDATEINIFILE);
62 }
63 return true ;
64 }
65
66 }
67 }
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值