窗體打開滿屏(非最大化),點擊按鈕全屏,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; }
新聞熱點
疑難解答