Exemplo n.º 1
0
 private void WmNccalcsize(ref Message m)
 {
     base.WndProc(ref m);
     if (this.RenderWithVisualStyles())
     {
         NativeMethods.NCCALCSIZE_PARAMS nCCALCSIZE_PARAMS = default(NativeMethods.NCCALCSIZE_PARAMS);
         NativeMethods.RECT rECT;
         if (m.WParam == IntPtr.Zero)
         {
             rECT = (NativeMethods.RECT)Marshal.PtrToStructure(m.LParam, typeof(NativeMethods.RECT));
         }
         else
         {
             nCCALCSIZE_PARAMS = (NativeMethods.NCCALCSIZE_PARAMS)Marshal.PtrToStructure(m.LParam, typeof(NativeMethods.NCCALCSIZE_PARAMS));
             rECT = nCCALCSIZE_PARAMS.rgrc0;
         }
         IntPtr             windowDC = NativeMethods.GetWindowDC(base.Handle);
         IntPtr             hTheme   = NativeMethods.OpenThemeData(base.Handle, "EDIT");
         NativeMethods.RECT rECT2;
         if (NativeMethods.GetThemeBackgroundContentRect(hTheme, windowDC, 1, 1, ref rECT, out rECT2) == 0)
         {
             rECT2.Inflate(-1, -1);
             this.borderRect = checked (new NativeMethods.RECT(rECT2.Left - rECT.Left, rECT2.Top - rECT.Top, rECT.Right - rECT2.Right, rECT.Bottom - rECT2.Bottom));
             if (m.WParam == IntPtr.Zero)
             {
                 Marshal.StructureToPtr(rECT2, m.LParam, false);
             }
             else
             {
                 nCCALCSIZE_PARAMS.rgrc0 = rECT2;
                 Marshal.StructureToPtr(nCCALCSIZE_PARAMS, m.LParam, false);
             }
             m.Result = new IntPtr(768);
         }
         NativeMethods.CloseThemeData(hTheme);
         NativeMethods.ReleaseDC(base.Handle, windowDC);
     }
 }