十一月 18th, 2010

C# 程序启动如何使用全屏展示不显示状态栏

应用程序研发解决方案, by 小哥.

事件编号:20101118001

方法一
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
/*******************************
* 程序启动全屏
* Hewill
* 2009-08-21
******************************/
namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

public const int HWND_NOTOPMOST= -2;
public const int SWP_SHOWWINDOW=0x0040;
[DllImport(“user32.dll”)]
private static extern IntPtr FindWindowEx(int hwnd2, int hWnd2, string lpsz1, string lpsz2);
[DllImport(“user32.dll”)]
private static extern int GetWindowLong (IntPtr hwnd, int nIndex);
[DllImport(“user32.dll”)]
private static extern int SetWindowPos(IntPtr hwnd, int hWndInsertAfter, int x, int y, int cx, int cy, int wFlags);
private void Form1_Load(object sender, EventArgs e)
{
IntPtr test = FindWindowEx(0, 0, “Shell_TrayWnd”, “”);
Console.WriteLine(test.ToString());
int test5 = SetWindowPos(test, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_SHOWWINDOW);
this.TopMost = true;
this.FormBorderStyle = FormBorderStyle.None;
this.Width = Screen.PrimaryScreen.Bounds.Width;
this.Height = Screen.PrimaryScreen.Bounds.Height;
this.Top = 0;
this.Left = 0;
}
}
}

方法二:
private void button1_Click(object sender, EventArgs e)
{
if (this.FormBorderStyle == FormBorderStyle.None)
{
this.FormBorderStyle = FormBorderStyle.FixedSingle;
this.WindowState = FormWindowState.Normal;
}
else
{
this.FormBorderStyle = FormBorderStyle.None;
this.WindowState = FormWindowState.Maximized;
}
}

Back Top