Fix white flash when starting GameWindow based application on windows

This commit is contained in:
Dean Herbert 2017-07-25 11:37:44 +09:00
parent 541df66b1f
commit e44aba39ed
2 changed files with 30 additions and 3 deletions

View file

@ -1421,9 +1421,8 @@ namespace OpenTK.Platform.Windows
}
}
[DllImport("gdi32.dll", SetLastError = true)]
internal static extern IntPtr GetStockObject(int index);
internal static extern IntPtr GetStockObject(StockObjects fnObject);
[DllImport("gdi32.dll", SetLastError = true)]
internal static extern BOOL DeleteObject([In]IntPtr hObject);
@ -3936,6 +3935,33 @@ namespace OpenTK.Platform.Windows
Baltic = 186,
}
/// <summary>
/// Identifiers for the GetStockObject method.
/// </summary>
internal enum StockObjects
{
WHITE_BRUSH = 0,
LTGRAY_BRUSH = 1,
GRAY_BRUSH = 2,
DKGRAY_BRUSH = 3,
BLACK_BRUSH = 4,
NULL_BRUSH = 5,
HOLLOW_BRUSH = NULL_BRUSH,
WHITE_PEN = 6,
BLACK_PEN = 7,
NULL_PEN = 8,
OEM_FIXED_FONT = 10,
ANSI_FIXED_FONT = 11,
ANSI_VAR_FONT = 12,
SYSTEM_FONT = 13,
DEVICE_DEFAULT_FONT = 14,
DEFAULT_PALETTE = 15,
SYSTEM_FIXED_FONT = 16,
DEFAULT_GUI_FONT = 17,
DC_BRUSH = 18,
DC_PEN = 19,
}
internal enum MapVirtualKeyType
{
/// <summary>uCode is a virtual-key code and is translated into a scan code. If it is a virtual-key code that does not distinguish between left- and right-hand keys, the left-hand scan code is returned. If there is no translation, the function returns 0.</summary>

View file

@ -735,7 +735,7 @@ namespace OpenTK.Platform.Windows
break;
case WindowMessage.ERASEBKGND:
return new IntPtr(1);
break;
case WindowMessage.WINDOWPOSCHANGED:
HandleWindowPositionChanged(handle, message, wParam, lParam);
@ -942,6 +942,7 @@ namespace OpenTK.Platform.Windows
{
ExtendedWindowClass wc = new ExtendedWindowClass();
wc.Size = ExtendedWindowClass.SizeInBytes;
wc.Background = Functions.GetStockObject(StockObjects.BLACK_BRUSH);
wc.Style = DefaultClassStyle;
wc.Instance = Instance;
wc.WndProc = WindowProcedureDelegate;