I want to get the size of a window being resized (I will show a tooltip by the mouse).

I have the code below:

protected override void WndProc(ref Message m)
            base.WndProc(ref m);
            if (m.Msg == WM_WINDOWPOSCHANGING)
                WindowPos mwp;
                mwp = (WindowPos)Marshal.PtrToStructure(m.LParam, typeof(WindowPos));
                //mwp.flags = mwp.flags | 1; // 1 is the NOSIZE flag
                if (mwp.x != 0
                    && mwp.hwnd != this.handle
                    && mwp.hwndInsertAfter != this.handle)
                    MessageBox.Show( + " x " +;
                m.Result = (IntPtr)0;

        public struct WindowPos
            public IntPtr hwnd;
            public IntPtr hwndInsertAfter;
            public int x;
            public int y;
            public int cx;
            public int cy;
            public uint flags;

I think I have to set a hook for it, but I am unsure of how to. Any help would help a lot.

Edited 6 Years Ago by bbman: n/a

this.Width;         //to get 
this.Width = 500;   //to set
this.Height;        //to get
this.Height = 500;  //to set


This article has been dead for over six months. Start a new discussion instead.