public static extern bool GetWindowPlacement(IntPtr hWnd, ref WINDOWPLACEMENT lpwndpl);
private void ResizeWindow(IntPtr hWnd_p, ref RECT rect_p) { WINDOWPLACEMENT placement = new WINDOWPLACEMENT(); Win32.GetWindowPlacement(hWnd_p, ref placement); int MARGIN_TOP = 0; int MARGIN_LEFT = 0; int MARGIN_BOTTOM = 0; int MARGIN_RIGHT = 0; isMaximised_i = (ShowWindowCommands.Maximized == placement.showCmd); if (isMaximised_i) { // // For some reason, when maximised, the window position appears to be off the screen // so need to move it in a bit. // Debug("It's maximised"); MARGIN_TOP = 8; MARGIN_LEFT = 8; MARGIN_BOTTOM = 8; MARGIN_RIGHT = 8; } this.Location = new Point(rect_p.Left + MARGIN_LEFT, rect_p.Top + MARGIN_TOP); this.Width = rect_p.Width - (MARGIN_LEFT + MARGIN_RIGHT); this.Height = rect_p.Height - (MARGIN_BOTTOM + MARGIN_TOP); // // Fix for issue #1 - set the 'top most' attribute again to make sure it doesn't go // down the z-order pecking order when other top most windows appear. // this.TopMost = true; this.Show(); }