From 68750e45b109e212461faa8001c816af1dff7f08 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 19 Nov 2015 08:34:59 +0100 Subject: [PATCH] shader_dlg_init - some code reuse --- gfx/common/win32_common.cpp | 8 ++++++-- ui/drivers/ui_win32.c | 9 +-------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/gfx/common/win32_common.cpp b/gfx/common/win32_common.cpp index 89511fb25c..2a438a42ea 100644 --- a/gfx/common/win32_common.cpp +++ b/gfx/common/win32_common.cpp @@ -261,14 +261,18 @@ bool win32_window_init(WNDCLASSEX *wndclass, bool fullscreen, const char *class_ if (!fullscreen) wndclass->hbrBackground = (HBRUSH)COLOR_WINDOW; - if (class_name != NULL) + if (class_name == NULL) wndclass->lpfnWndProc = WndProc; + else + wndclass->style |= CS_CLASSDC; if (!RegisterClassEx(wndclass)) return false; + /* This is non-NULL when we want a window for shader dialogs, + * therefore early return here */ /* TODO/FIXME - this is ugly. Find a better way */ - if (class_name != NULL) /* this is non-NULL when we want a window for shader dialogs, abort here */ + if (class_name != NULL) return true; if (!win32_shader_dlg_init()) diff --git a/ui/drivers/ui_win32.c b/ui/drivers/ui_win32.c index 84b328d0b7..538465dbac 100644 --- a/ui/drivers/ui_win32.c +++ b/ui/drivers/ui_win32.c @@ -376,17 +376,10 @@ bool win32_shader_dlg_init(void) if (!InitCommonControlsEx(&comm_ctrl_init)) return false; - wc_shader_dlg.cbSize = sizeof(wc_shader_dlg); - wc_shader_dlg.style = CS_HREDRAW | CS_VREDRAW | CS_CLASSDC | CS_OWNDC; wc_shader_dlg.lpfnWndProc = ShaderDlgWndProc; - wc_shader_dlg.hInstance = GetModuleHandle(NULL); - wc_shader_dlg.hCursor = LoadCursor(NULL, IDC_ARROW); - wc_shader_dlg.lpszClassName = "Shader Dialog"; - wc_shader_dlg.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON)); - wc_shader_dlg.hIconSm = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON), IMAGE_ICON, 16, 16, 0); wc_shader_dlg.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1); - if (!RegisterClassEx(&wc_shader_dlg)) + if (!win32_window_init(&wc_shader_dlg, true, "Shader Dialog")) return false; inited = true;