【C#】C#winform 双击/按"F12"键全屏,按"Esc"键退出

来源:互联网 发布:骁龙835支持5g网络吗 编辑:程序博客网 时间:2024/04/26 19:31
private void Lottery_DBClick(object sender, EventArgs e)
        {
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;// 设置边框为 None
            this.WindowState = FormWindowState.Maximized;// 最大化
            this.TopMost = true;// 置顶
            this.KeyPreview = true;// 允许窗体先收到键盘事件
            this.KeyUp += new KeyEventHandler(Lottery_KeyUp);// 允许窗体先收到键盘事件
            this.Show();//显示 Form
        }


        private void Lottery_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Escape)//"Esc"按键退出全屏
            {
                this.WindowState = FormWindowState.Normal;
                this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable;
            }


            if (e.KeyCode == Keys.F12)
            {
                this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;// 设置边框为 None
                this.WindowState = FormWindowState.Maximized;// 最大化
                this.TopMost = true;// 置顶
                this.KeyPreview = true;// 允许窗体先收到键盘事件
                this.KeyUp += new KeyEventHandler(Lottery_KeyUp);// 允许窗体先收到键盘事件
                this.Show();//显示 Form
            }
        }
0 0
原创粉丝点击