Completed implementation of WindowBorder and WindowState properties.

This commit is contained in:
the_fiddler 2008-04-21 20:18:39 +00:00
parent 26f91baaec
commit aba6cdadef

View file

@ -92,26 +92,35 @@ namespace OpenTK.Platform.Windows
WindowPosition pos = (WindowPosition)Marshal.PtrToStructure(m.LParam, typeof(WindowPosition)); WindowPosition pos = (WindowPosition)Marshal.PtrToStructure(m.LParam, typeof(WindowPosition));
position.X = pos.x; position.X = pos.x;
position.Y = pos.y; position.Y = pos.y;
window_size.Width = pos.cx; window_size.Width = pos.cx;
window_size.Height = pos.cy; window_size.Height = pos.cy;
Functions.GetClientRect(Handle, out client_rectangle); Functions.GetClientRect(Handle, out client_rectangle);
//client_size.Width = pos.cx - (left_border + right_border); break;
//client_size.Height = pos.cy - (top_border + bottom_border);
// Get window size case WindowMessage.STYLECHANGED:
//int _width = Marshal.ReadInt32(m.LParam, (int)Marshal.OffsetOf(typeof(WindowPosition), "cx")); WindowStyle style = (WindowStyle)(long)Functions.GetWindowLong(Handle, GetWindowLongOffsets.STYLE);
//int _height = Marshal.ReadInt32(m.LParam, (int)Marshal.OffsetOf(typeof(WindowPosition), "cy")); if ((style & WindowStyle.Popup) != 0)
windowBorder = WindowBorder.Hidden;
else if ((style & WindowStyle.ThickFrame) != 0)
windowBorder = WindowBorder.Resizable;
else if ((style & ~(WindowStyle.ThickFrame | WindowStyle.MaximizeBox)) != 0)
windowBorder = WindowBorder.Fixed;
break;
//if (client_size.Width != new_width || client_size.Height != new_height) case WindowMessage.SIZE:
//{ Console.WriteLine(m.WParam.ToString());
// client_size.Width = new_width; long state = m.WParam.ToInt64();
// client_size.Height = new_height; switch (state)
// return; {
//} case 0: windowState = WindowState.Normal; break;
case 1: windowState = WindowState.Minimized; break;
// If the message was not a resize notification, send it to the default WndProc. case 2:
windowState = WindowBorder == WindowBorder.Hidden ? WindowState.Fullscreen : WindowState.Maximized;
break;
}
break; break;
//case WindowMessage.MOUSELEAVE: //case WindowMessage.MOUSELEAVE:
@ -124,10 +133,12 @@ namespace OpenTK.Platform.Windows
case WindowMessage.CREATE: case WindowMessage.CREATE:
// Set the window width and height: // Set the window width and height:
width = Marshal.ReadInt32(m.LParam, (int)Marshal.OffsetOf(typeof(CreateStruct), "cx")); pos = (WindowPosition)Marshal.PtrToStructure(m.LParam, typeof(WindowPosition));
height = Marshal.ReadInt32(m.LParam, (int)Marshal.OffsetOf(typeof(CreateStruct), "cy")); position.X = pos.x;
width -= (left_border + right_border); position.Y = pos.y;
height -= (top_border + bottom_border);
window_size.Width = pos.cx;
window_size.Height = pos.cy;
// Raise the Create event // Raise the Create event
this.OnCreate(EventArgs.Empty); this.OnCreate(EventArgs.Empty);
@ -499,7 +510,7 @@ namespace OpenTK.Platform.Windows
Functions.ShowWindow(Handle, command); Functions.ShowWindow(Handle, command);
Functions.SetWindowPos(Handle, WindowPlacementOptions.TOP, 0, 0, new_width, new_height, flags); Functions.SetWindowPos(Handle, WindowPlacementOptions.TOP, 0, 0, new_width, new_height, flags);
windowState = value; //windowState = value;
} }
} }
@ -527,7 +538,7 @@ namespace OpenTK.Platform.Windows
break; break;
case WindowBorder.Fixed: case WindowBorder.Fixed:
style &= ~(WindowStyle.MaximizeBox | WindowStyle.ThickFrame | WindowStyle.SizeBox); style |= WindowStyle.OverlappedWindow & ~(WindowStyle.ThickFrame | WindowStyle.MaximizeBox | WindowStyle.SizeBox);
break; break;
case WindowBorder.Hidden: case WindowBorder.Hidden:
@ -536,8 +547,10 @@ namespace OpenTK.Platform.Windows
} }
Functions.SetWindowLong(Handle, GetWindowLongOffsets.STYLE, (IntPtr)(int)style); 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);
windowBorder = value; //windowBorder = value;
} }
} }