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.
This commit is contained in:
parent
6452cf4629
commit
331b7d0f63
1 changed files with 6 additions and 14 deletions
|
@ -47,8 +47,8 @@ namespace OpenTK.Platform.Windows
|
||||||
|
|
||||||
readonly static object SyncRoot = new object();
|
readonly static object SyncRoot = new object();
|
||||||
|
|
||||||
readonly static ExtendedWindowStyle ParentStyleEx = ExtendedWindowStyle.WindowEdge;
|
const ExtendedWindowStyle ParentStyleEx = ExtendedWindowStyle.WindowEdge | ExtendedWindowStyle.ApplicationWindow;
|
||||||
readonly static ExtendedWindowStyle ChildStyleEx = 0;
|
const ExtendedWindowStyle ChildStyleEx = 0;
|
||||||
|
|
||||||
readonly IntPtr Instance = Marshal.GetHINSTANCE(typeof(WinGLNative).Module);
|
readonly IntPtr Instance = Marshal.GetHINSTANCE(typeof(WinGLNative).Module);
|
||||||
readonly IntPtr ClassName;
|
readonly IntPtr ClassName;
|
||||||
|
@ -152,6 +152,7 @@ namespace OpenTK.Platform.Windows
|
||||||
|
|
||||||
IntPtr WindowProcedure(IntPtr handle, WindowMessage message, IntPtr wParam, IntPtr lParam)
|
IntPtr WindowProcedure(IntPtr handle, WindowMessage message, IntPtr wParam, IntPtr lParam)
|
||||||
{
|
{
|
||||||
|
Debug.WriteLine(message.ToString());
|
||||||
switch (message)
|
switch (message)
|
||||||
{
|
{
|
||||||
#region Size / Move / Style events
|
#region Size / Move / Style events
|
||||||
|
@ -555,22 +556,13 @@ namespace OpenTK.Platform.Windows
|
||||||
wc.WndProc = WindowProcedureDelegate;
|
wc.WndProc = WindowProcedureDelegate;
|
||||||
wc.ClassName = ClassName;
|
wc.ClassName = ClassName;
|
||||||
wc.Icon = Icon != null ? Icon.Handle : IntPtr.Zero;
|
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.Cursor = Functions.LoadCursor(CursorName.Arrow);
|
||||||
//wc.Background = Functions.GetStockObject(5);
|
|
||||||
ushort atom = Functions.RegisterClassEx(ref wc);
|
ushort atom = Functions.RegisterClassEx(ref wc);
|
||||||
|
|
||||||
if (atom == 0)
|
if (atom == 0)
|
||||||
{
|
throw new PlatformException(String.Format("Failed to register window class. Error: {0}", Marshal.GetLastWin32Error()));
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class_registered = true;
|
class_registered = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue