Fixed SetWindowPos function (IntPtr instead of int parameter).
Add NcCalcSizeOptions enum.
This commit is contained in:
parent
501a728532
commit
c6f5131491
2 changed files with 28 additions and 7 deletions
|
@ -104,7 +104,7 @@ namespace OpenTK.Platform.Windows
|
|||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern bool SetWindowPos(
|
||||
IntPtr handle,
|
||||
WindowPlacementOptions placement,
|
||||
IntPtr insertAfter,
|
||||
int x, int y, int cx, int cy,
|
||||
SetWindowPosFlags flags
|
||||
);
|
||||
|
@ -2460,6 +2460,22 @@ namespace OpenTK.Platform.Windows
|
|||
|
||||
#region --- Enums ---
|
||||
|
||||
#region
|
||||
|
||||
internal enum NcCalcSizeOptions
|
||||
{
|
||||
ALIGNTOP = 0x10,
|
||||
ALIGNRIGHT = 0x80,
|
||||
ALIGNLEFT = 0x20,
|
||||
ALIGNBOTTOM = 0x40,
|
||||
HREDRAW = 0x100,
|
||||
VREDRAW = 0x200,
|
||||
REDRAW = (HREDRAW | VREDRAW),
|
||||
VALIDRECTS = 0x400
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region internal enum DisplayModeSettingsEnum
|
||||
|
||||
internal enum DisplayModeSettingsEnum
|
||||
|
|
|
@ -88,6 +88,10 @@ namespace OpenTK.Platform.Windows
|
|||
case WindowMessage.ACTIVATE:
|
||||
break;
|
||||
|
||||
case WindowMessage.NCCALCSIZE:
|
||||
// Need to update the client rectangle, because it has the wrong size on Vista with Aero enabled.
|
||||
break;
|
||||
|
||||
case WindowMessage.WINDOWPOSCHANGED:
|
||||
WindowPosition pos = (WindowPosition)Marshal.PtrToStructure(m.LParam, typeof(WindowPosition));
|
||||
position.X = pos.x;
|
||||
|
@ -363,7 +367,7 @@ namespace OpenTK.Platform.Windows
|
|||
"Could not create native window and/or context. Handle: {0}",
|
||||
this.Handle));
|
||||
|
||||
Functions.SetWindowPos(this.Handle, WindowPlacementOptions.TOP, Left, Top, rect.right - rect.left,
|
||||
Functions.SetWindowPos(this.Handle, IntPtr.Zero, Left, Top, rect.right - rect.left,
|
||||
rect.bottom - rect.top, SetWindowPosFlags.SHOWWINDOW);
|
||||
|
||||
context = new GraphicsContext(mode, window);
|
||||
|
@ -509,7 +513,7 @@ namespace OpenTK.Platform.Windows
|
|||
}
|
||||
|
||||
Functions.ShowWindow(Handle, command);
|
||||
Functions.SetWindowPos(Handle, WindowPlacementOptions.TOP, 0, 0, new_width, new_height, flags);
|
||||
Functions.SetWindowPos(Handle, IntPtr.Zero, 0, 0, new_width, new_height, flags);
|
||||
|
||||
//windowState = value;
|
||||
}
|
||||
|
@ -549,8 +553,9 @@ namespace OpenTK.Platform.Windows
|
|||
}
|
||||
|
||||
Functions.SetWindowLong(Handle, GetWindowLongOffsets.STYLE, (IntPtr)(int)style);
|
||||
Functions.SetWindowPos(Handle, WindowPlacementOptions.TOP, 0, 0, 0, 0, SetWindowPosFlags.NOMOVE |
|
||||
SetWindowPosFlags.NOSIZE | SetWindowPosFlags.FRAMECHANGED | SetWindowPosFlags.SHOWWINDOW);
|
||||
Functions.SetWindowPos(Handle, IntPtr.Zero, 0, 0, 0, 0,
|
||||
SetWindowPosFlags.NOMOVE | SetWindowPosFlags.NOSIZE | SetWindowPosFlags.NOZORDER | SetWindowPosFlags.NOACTIVATE |
|
||||
SetWindowPosFlags.FRAMECHANGED | SetWindowPosFlags.SHOWWINDOW | SetWindowPosFlags.DRAWFRAME);
|
||||
|
||||
//windowBorder = value;
|
||||
}
|
||||
|
@ -576,7 +581,7 @@ namespace OpenTK.Platform.Windows
|
|||
if (value <= 0) throw new ArgumentOutOfRangeException("Window width must be higher than zero.");
|
||||
//if (WindowState == WindowState.Fullscreen || WindowState == WindowState.Maximized)
|
||||
// throw new InvalidOperationException("Cannot resize a fullscreen or maximized window.");
|
||||
Functions.SetWindowPos(Handle, WindowPlacementOptions.TOP, 0, 0, value, Height, SetWindowPosFlags.NOMOVE);
|
||||
Functions.SetWindowPos(Handle, IntPtr.Zero, 0, 0, value, Height, SetWindowPosFlags.NOMOVE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -594,7 +599,7 @@ namespace OpenTK.Platform.Windows
|
|||
set
|
||||
{
|
||||
if (value <= 0) throw new ArgumentOutOfRangeException("Window height must be higher than zero.");
|
||||
Functions.SetWindowPos(Handle, WindowPlacementOptions.TOP, 0, 0, Width, value, SetWindowPosFlags.NOMOVE);
|
||||
Functions.SetWindowPos(Handle, IntPtr.Zero, 0, 0, Width, value, SetWindowPosFlags.NOMOVE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue