Results 1 to 4 of 4

Thread: [2.0] Custom border form problem (Advanced. Guru needed)

Threaded View

  1. #1

    Thread Starter
    Fanatic Member BrianHawley's Avatar
    Join Date
    Aug 2001
    Location
    Saudi Arabia
    Posts
    796

    [2.0] Custom border form problem (Advanced. Guru needed)

    I'm having a problem processing the WM_NCCALCSIZE message to redefine the border widths of a form.

    This is the code:

    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;
          }
        }
    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.

    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!!!!
    Attached Files Attached Files
    Brian
    (Fighting with the RightToLeft bugs in VS 2005)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width