天天看点

c# winform 让Form窗体上系统自带的红色关闭按钮失效,点击关闭变为隐藏

c# winform 让Form窗体上系统自带的红色关闭按钮失效,点击关闭变为隐藏
c# winform 让Form窗体上系统自带的红色关闭按钮失效,点击关闭变为隐藏

代码

        #region   拦截Windows消息

        protected override void WndProc(ref   Message m)

        {

            const int WM_SYSCOMMAND = 0x0112;

            const int SC_CLOSE = 0xF060;

            if (m.Msg == WM_SYSCOMMAND && (int)m.WParam == SC_CLOSE)

            {

                //捕捉关闭窗体消息      

                //   User   clicked   close   button      

                this.Hide();

                return;

            }

            base.WndProc(ref   m);

        }

        #endregion  

继续阅读