通常c# form里面的最小化按钮点击的时候
这个最小化触发的是什么事件?
我想在form收缩之前记录一下form的位置,不知道该怎么记录???

解决方案 »

  1.   

    protected override void DefWndProc(ref Message m) {
                switch (m.Msg) {
                    case WM_SIZE:
                        if(m.WParam.ToInt32() == SIZE_MAXIMIZED) {
                            // 窗体最大化
                            Console.WriteLine("Maxmized");
                        }else if(m.WParam.ToInt32() == SIZE_MINIMIZED) {
                            // 窗体最小花
                            Console.WriteLine("Minimized");
                        }else {
                            base.DefWndProc(ref m);
                        }
                        break;
                    default:
                        base.DefWndProc(ref m);
                        break;
                }
            }        private const int WM_SIZE = 0x0005;
            const int SIZE_MAXIMIZED = 2;
            const int SIZE_MINIMIZED = 1;
      

  2.   

    private Point m_TempPoiont;
    private Point m_LastPoint;private void Form1_LocationChanged(object sender, EventArgs e)
    {
    if (this.Location.X == -32000 && this.Location.Y == -32000)
    {
    m_LastPoint = m_TempPoiont;//最小化了,m_LastPoint就是最小化前的位置。
    }
    else
    {
    m_TempPoiont = this.Location;
    }
    }