您的位置:首页 > 其它

重回博客园

2014-04-03 08:57 120 查看
暂别AS3生涯,重回C#,今天开始整理头绪写个随笔。

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

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices; // Important!

namespace FullScreenExample
{
public partial class Form1 : Form
{
[DllImport("user32.dll")]
private static extern int FindWindow(string lpszClassName, string lpszWindowName);
[DllImport("user32.dll")]
private static extern int ShowWindow(int hWnd, int nCmdShow);

private const int SW_HIDE = 0;
private const int SW_SHOW = 1;

private void full_maximize(object sender, EventArgs e)
{
//隐藏任务栏

int hWnd = FindWindow("Shell_TrayWnd", "");
ShowWindow(hWnd, SW_HIDE);

FormBorderStyle = FormBorderStyle.None;
this.Location = new Point(0, 0);
this.WindowState = FormWindowState.Maximized;
}

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
full_maximize(sender, e);
}

private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
int hwnd = FindWindow("Shell_TrayWnd", "");
ShowWindow(hwnd, SW_SHOW);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: