新文章 网摘 文章 随笔 日记

WinForm检测最大化最小化事件

const int ScMinimize = 0xF020;//窗体最小化消息
const int ScMaximize = 0xF030;//窗体最大化消息
const int ScNomal = 0xF120;//窗体还原消息

protected override void WndProc(ref Message m)
        {
            //如果是系统命令
            if (m.Msg == 0x0112)
            {
                Debug.WriteLine($@"WndProc  _tempWindowState:{_tempWindowState};WindowState:{WindowState};top:{Top};left:{Left};width:{Width};height:{Height}");

                //如果是最小化
                if (m.WParam == new IntPtr(ScMinimize))
                {
                   
                }

                //还原
                if (m.WParam == new IntPtr(ScNomal))
                {

                }

                // 最大化
                if (m.WParam == new IntPtr(ScMaximize))
                {

                }


                m.Result = new IntPtr(0);
            }

            base.WndProc(ref m);
        }

 

posted @ 2023-09-14 15:26  岭南春  阅读(507)  评论(0)    收藏  举报