窗体打开满屏(非最大化),点击按钮全屏,ESC键按下时推出全屏:
public Form1() { InitializeComponent(); KeyPReview = true; DoubleBuffered = true; StartPosition = FormStartPosition.Manual; //窗体的位置由 Forms.Control.Location 属性确定。 Rectangle rect = Screen.GetWorkingArea(this); this.Width = rect.Width; this.Height = rect.Height; } private void fullscreen_Click(object sender, EventArgs e) { this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.WindowState = System.Windows.Forms.FormWindowState.Maximized; } private void Form1_KeyDown(object sender, KeyEventArgs e) { switch (e.KeyCode) { case Keys.Escape: returnback(); break; default: break; } } private void returnback() { this.WindowState = FormWindowState.Normal; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable; }
新闻热点
疑难解答