From 331b7d0f6397f85c813d69dbdb7e58a07c9bc07e Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Wed, 4 Nov 2009 09:21:41 +0000 Subject: [PATCH] Default window style flags can be constants rather than static readonly fields. Throw an exception if we fail to register the window class, the previous solution (check for "class already exists" error) was a workaround for a threading issue that has been solved. Set the small icon when registering the class. --- Source/OpenTK/Platform/Windows/WinGLNative.cs | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/Source/OpenTK/Platform/Windows/WinGLNative.cs b/Source/OpenTK/Platform/Windows/WinGLNative.cs index 35d1f87d..5a70cea4 100644 --- a/Source/OpenTK/Platform/Windows/WinGLNative.cs +++ b/Source/OpenTK/Platform/Windows/WinGLNative.cs @@ -47,8 +47,8 @@ namespace OpenTK.Platform.Windows readonly static object SyncRoot = new object(); - readonly static ExtendedWindowStyle ParentStyleEx = ExtendedWindowStyle.WindowEdge; - readonly static ExtendedWindowStyle ChildStyleEx = 0; + const ExtendedWindowStyle ParentStyleEx = ExtendedWindowStyle.WindowEdge | ExtendedWindowStyle.ApplicationWindow; + const ExtendedWindowStyle ChildStyleEx = 0; readonly IntPtr Instance = Marshal.GetHINSTANCE(typeof(WinGLNative).Module); readonly IntPtr ClassName; @@ -152,6 +152,7 @@ namespace OpenTK.Platform.Windows IntPtr WindowProcedure(IntPtr handle, WindowMessage message, IntPtr wParam, IntPtr lParam) { + Debug.WriteLine(message.ToString()); switch (message) { #region Size / Move / Style events @@ -555,22 +556,13 @@ namespace OpenTK.Platform.Windows wc.WndProc = WindowProcedureDelegate; wc.ClassName = ClassName; wc.Icon = Icon != null ? Icon.Handle : IntPtr.Zero; +#warning "This seems to resize one of the 'large' icons, rather than using a small icon directly (multi-icon files). Investigate!" + wc.IconSm = Icon != null ? new Icon(Icon, 16, 16).Handle : IntPtr.Zero; wc.Cursor = Functions.LoadCursor(CursorName.Arrow); - //wc.Background = Functions.GetStockObject(5); ushort atom = Functions.RegisterClassEx(ref wc); if (atom == 0) - { - int error= Marshal.GetLastWin32Error(); - Debug.Print("Failed to register class {0}, due to error {1}.", Marshal.PtrToStringAuto(ClassName), error); - - // Error 1410 means "class already exists", which means we'll just go ahead and use it. - // In all other cases, we'll throw an exception and stop execution. - if (error != 1410) - { - throw new PlatformException(String.Format("Failed to register window class. Error: {0}", error)); - } - } + throw new PlatformException(String.Format("Failed to register window class. Error: {0}", Marshal.GetLastWin32Error())); class_registered = true; }