AdvancedLauncher.Tools.Interop.RedirectedWindow.SetClientAreaSize C# (CSharp) Method

SetClientAreaSize() public method

Sizes the window such that the client area has the specified size.
public SetClientAreaSize ( int width, int height ) : bool
width int
height int
return bool
        public bool SetClientAreaSize(int width, int height)
        {
            POINT ptClient = new POINT();
            NativeMethods.ClientToScreen(Handle, ref ptClient);

            RECT rect = new RECT();
            rect.left = ptClient.x;
            rect.top = ptClient.y;
            rect.right = rect.left + width;
            rect.bottom = rect.top + height;

            WS style = (WS)NativeMethods.GetWindowLong(Handle, GWL.STYLE);
            WS_EX exStyle = (WS_EX)NativeMethods.GetWindowLong(Handle, GWL.EXSTYLE);
            NativeMethods.AdjustWindowRectEx(ref rect, style, false, exStyle);

            NativeMethods.SetWindowPos(
                Handle,
                HWND.NULL,
                rect.left,
                rect.top,
                rect.width,
                rect.height,
                SWP.NOZORDER | SWP.NOCOPYBITS);

            NativeMethods.GetClientRect(Handle, ref rect);
            return rect.width == width && rect.height == height;
        }