I'm having a problem processing the WM_NCCALCSIZE message to redefine the border widths of a form.
This is the code:
Works perfectly - that is until the user maximizes and normalizes the form, then the size of the @#!##@% form changes! i.e. it does not restore to the proper size.Code:private void WmNCCalcSize(ref Message m) { if (m.WParam.ToInt32() == 0) { RECT rc = (RECT)m.GetLParam(typeof(RECT)); rc.Left += 120; rc.Top += 20; rc.Right -= 20; rc.Bottom -= 20; Marshal.StructureToPtr(rc, m.LParam, true); m.Result = IntPtr.Zero; } else { NCCALCSIZE_PARAMS csp; csp = (NCCALCSIZE_PARAMS)m.GetLParam(typeof(NCCALCSIZE_PARAMS)); csp.rgrc0.Top += 120; csp.rgrc0.Bottom -= 20; csp.rgrc0.Left += 20; csp.rgrc0.Right -= 20; Marshal.StructureToPtr(csp, m.LParam, true); //Return zero to preserve client rectangle m.Result = IntPtr.Zero; } }
It's driving me nuts.
A small and rather messy project illustrating the problem is attached. Sorry, it's a rar as I don't have WinZip on this machine.
Any ideas? Can it be a DotNet bug?
Help!!!!




Reply With Quote