http://msdn.microsoft.com/en-us/library/ms632653(VS.85).aspx

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(mwp.cx.ToString() + " x " + mwp.cy.ToString());
                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.
Thanks.

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

enjoy

Hey,
Thanks for the reply, but I want it for every window.

formName.Width or Height

sorry m8 can't help you with that, gotta wait for someone who knows.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.