private void AdjustWindow(int clientWidth, int clientHeight,
ref int winWidth, ref int winHeight)
{
// NB only call this for non full screen
var rc = new System.Drawing.Rectangle( 0, 0, clientWidth, clientHeight );
AdjustWindowRect( ref rc, GetWindowStyle( isFullScreen ), false );
winWidth = rc.Right - rc.Left;
winHeight = rc.Bottom - rc.Top;
// adjust to monitor
// Get monitor info
var handle = hWnd != null ? hWnd.Handle : IntPtr.Zero;
var monitorInfo = DisplayMonitor.FromWindow( handle, MonitorSearchFlags.DefaultToNearest );
var maxW = monitorInfo.WorkingArea.Right - monitorInfo.WorkingArea.Left;
var maxH = monitorInfo.WorkingArea.Bottom - monitorInfo.WorkingArea.Top;
if (winWidth > maxW)
winWidth = maxW;
if (winHeight > maxH)
winHeight = maxH;
}