擷取标題欄高度,左右邊框的寬度和下邊框的高度
public class NonClientSize
{
public int TitleBar = 0;
public int LeftBorder = 0;
public int RightBorder = 0;
public int BottomBorder = 0;
}
protected NonClientSize GetNonClientSize()
{
NativeMethods.RECT rect = new NativeMethods.RECT();
rect.Left = rect.Right = rect.Top = rect.Bottom = 0;
var cp = CreateParams;//Form
SafeNativeMethods.AdjustWindowRectEx(ref rect, cp.Style, false, cp.ExStyle);
var nonClientSize = new NonClientSize();
nonClientSize.TitleBar = Math.Abs(rect.Top);
nonClientSize.LeftBorder = Math.Abs(rect.Left);
nonClientSize.RightBorder = rect.Right;
nonClientSize.BottomBorder = rect.Bottom;
return nonClientSize;
}