public static void AdaptWindowToWorkingArea(this IntPtr windowHandle, int?taskbarHeight = null) { SEBWindowHandler.EditWindowByHandle(windowHandle, SEBWindowHandler.ShowWindowCommand.SW_SHOWNORMAL, false); if (taskbarHeight.HasValue) { IntPtr hWnd = windowHandle; int X = 0; int Y = 0; Rectangle bounds = Screen.PrimaryScreen.Bounds; int width = bounds.Width; bounds = Screen.PrimaryScreen.Bounds; int nHeight = bounds.Height - taskbarHeight.Value; int num = 1; SEBWindowHandler.MoveWindow(hWnd, X, Y, width, nHeight, num != 0); } else { IntPtr hWnd = windowHandle; int X = 0; int Y = 0; Rectangle rectangle = Screen.PrimaryScreen.Bounds; int width = rectangle.Width; rectangle = Screen.PrimaryScreen.WorkingArea; int height = rectangle.Height; int num = 1; SEBWindowHandler.MoveWindow(hWnd, X, Y, width, height, num != 0); } SEBWindowHandler.EditWindowByHandle(windowHandle, SEBWindowHandler.ShowWindowCommand.SW_SHOWMAXIMIZED, false); }