C# WINFORM 按ESC关闭窗口

protected override bool ProcessCmdKey(ref System.Windows.Forms.Message msg, System.Windows.Forms.Keys keyData)
        {

            int WM_KEYDOWN = 256;

            int WM_SYSKEYDOWN = 260;

            if (msg.Msg == WM_KEYDOWN | msg.Msg == WM_SYSKEYDOWN)
            {

                switch (keyData)
                {

                    case Keys.Escape:

                        Application.Exit();

                        break;

                }

 

            }

            return false;

        }

posted @ 2020-12-04 13:49  左正  阅读(1003)  评论(0编辑  收藏  举报