/// <summary> /// 设置控件的工作区的高度和宽度。 /// </summary> /// <param name="hWnd">控件句柄。</param> /// <param name="value">一个 System.Drawing.Size,表示控件的工作区的维数。</param> public static void SetClientSize(IntPtr hWnd, Size value) { NativeMethods.RECT lpRect = new NativeMethods.RECT(0, 0, value.Width, value.Height); int dwStyle = UnsafeNativeMethods.GetWindowLong(hWnd, NativeMethods.GWL_STYLE); int dwExStyle = UnsafeNativeMethods.GetWindowLong(hWnd, NativeMethods.GWL_EXSTYLE); UnsafeNativeMethods.AdjustWindowRectEx(ref lpRect, dwStyle, false, dwExStyle); SetSize(hWnd, lpRect.Size); }