重回博客园

暂别AS3生涯,重回C#,今天开始整理头绪写个随笔。

 

关于Winform全屏的问题,网上的资料,都是差不多,将Window窗口最大化,然后去除边框和任务栏

 

 1 using System;
 2 using System.Collections.Generic;
 3 using System.ComponentModel;
 4 using System.Data;
 5 using System.Drawing;
 6 using System.Text;
 7 using System.Windows.Forms;
 8 using System.Runtime.InteropServices; // Important!
 9 
10 namespace FullScreenExample
11 {
12     public partial class Form1 : Form
13     {
14         [DllImport("user32.dll")]
15         private static extern int FindWindow(string lpszClassName, string lpszWindowName);
16         [DllImport("user32.dll")]
17         private static extern int ShowWindow(int hWnd, int nCmdShow);
18 
19         private const int SW_HIDE = 0;
20         private const int SW_SHOW = 1;
21 
22         private void full_maximize(object sender, EventArgs e)
23         {
24             //隐藏任务栏
25 
26             int hWnd = FindWindow("Shell_TrayWnd", "");
27             ShowWindow(hWnd, SW_HIDE);
28 
29             FormBorderStyle = FormBorderStyle.None;
30             this.Location = new Point(0, 0);
31             this.WindowState = FormWindowState.Maximized;
32         }
33 
34         public Form1()
35         {
36             InitializeComponent();
37         }
38 
39         private void Form1_Load(object sender, EventArgs e)
40         {
41             full_maximize(sender, e);
42         }
43 
44         private void Form1_FormClosing(object sender, FormClosingEventArgs e)
45         {
46             int hwnd = FindWindow("Shell_TrayWnd", "");
47             ShowWindow(hwnd, SW_SHOW);
48         }
49     }

 

 

 

posted @ 2014-04-03 08:57  Marksion  阅读(266)  评论(0编辑  收藏  举报