protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
switch (m.Msg)
{
case 0x0083://WM_NCCALCSIZE
AdjustClientRect(ref m);
break;
}
}
protected void AdjustClientRect(ref Message m)
{
if (m.WParam != IntPtr.Zero)
{
var rcsize =
(NCCALCSIZE_PARAMS)Marshal.PtrToStructure(m.LParam, typeof(NCCALCSIZE_PARAMS));
AdjustClientRect(ref rcsize.rcNewWindow);
Marshal.StructureToPtr(rcsize, m.LParam, false);
}
else
{
var rcsize = (RECT)Marshal.PtrToStructure(m.LParam, typeof(RECT));
AdjustClientRect(ref rcsize);
Marshal.StructureToPtr(rcsize, m.LParam, false);
}
m.Result = IntPtr.Zero;
}
protected void AdjustClientRect(ref RECT rcClient)
{
rcClient.Left += 2;
rcClient.Top += 2;
rcClient.Right -= 2;
rcClient.Bottom -= 2;
}
public struct RECT
{
/// <exclude/>
public int Left;
/// <exclude/>
public int Top;
/// <exclude/>
public int Right;
/// <exclude/>
public int Bottom;
}
public struct NCCALCSIZE_PARAMS
{
public RegionEx.RECT rcNewWindow;
public RegionEx.RECT rcOldWindow;
public RegionEx.RECT rcClient;
IntPtr lppos;
}