首页 > 学院 > 开发设计 > 正文

winfrom-窗体打开大小和全屏设置

2019-11-11 05:51:40
字体:
来源:转载
供稿:网友

窗体打开满屏(非最大化),点击按钮全屏,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;        }


上一篇:生日蜡烛

下一篇:随机 Random

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表