Construct windows invisible by default. Use 'Visible = true' or 'GameWindow.Run' to display them.

This commit is contained in:
the_fiddler 2009-09-08 13:04:22 +00:00
parent b41877e771
commit 542144ac7c

View file

@ -52,7 +52,6 @@ namespace OpenTK.Platform.Windows
readonly WindowProcedure WindowProcedureDelegate; readonly WindowProcedure WindowProcedureDelegate;
bool class_registered; bool class_registered;
bool visible = true;
bool disposed; bool disposed;
bool exists; bool exists;
WinWindowInfo window, child_window; WinWindowInfo window, child_window;
@ -462,14 +461,20 @@ namespace OpenTK.Platform.Windows
// Use win32 to create the native window. // Use win32 to create the native window.
// Keep in mind that some construction code runs in the WM_CREATE message handler. // Keep in mind that some construction code runs in the WM_CREATE message handler.
WindowStyle style = // The style of a parent window is different than that of a child window.
WindowStyle.Visible | // Note: the child window should always be visible, even if the parent isn't.
(parentHandle == IntPtr.Zero ? WindowStyle style = 0;
WindowStyle.OverlappedWindow | WindowStyle.ClipChildren : ExtendedWindowStyle ex_style = 0;
WindowStyle.Child | WindowStyle.ClipSiblings); if (parentHandle == IntPtr.Zero)
{
ExtendedWindowStyle ex_style = style |= WindowStyle.OverlappedWindow | WindowStyle.ClipChildren;
(parentHandle == IntPtr.Zero ? ParentStyleEx : ChildStyleEx); ex_style = ParentStyleEx;
}
else
{
style |= WindowStyle.Visible | WindowStyle.Child | WindowStyle.ClipSiblings;
ex_style = ChildStyleEx;
}
// Find out the final window rectangle, after the WM has added its chrome (titlebar, sidebars etc). // Find out the final window rectangle, after the WM has added its chrome (titlebar, sidebars etc).
Rectangle rect = new Rectangle(); Rectangle rect = new Rectangle();
@ -716,19 +721,17 @@ namespace OpenTK.Platform.Windows
{ {
get get
{ {
return visible; return Functions.IsWindowVisisble(window.WindowHandle);
} }
set set
{ {
if (value && !Visible) if (value)
{ {
Functions.ShowWindow(window.WindowHandle, ShowWindowCommand.SHOWNORMAL); Functions.ShowWindow(window.WindowHandle, ShowWindowCommand.SHOWNORMAL);
visible = true;
} }
else if (!value && Visible) else if (!value)
{ {
Functions.ShowWindow(window.WindowHandle, ShowWindowCommand.HIDE); Functions.ShowWindow(window.WindowHandle, ShowWindowCommand.HIDE);
visible = false;
} }
} }
} }