From 67eac6173a4758d20168bde0e01afcdd70985bd2 Mon Sep 17 00:00:00 2001 From: HuYingzhuo Date: Tue, 30 Apr 2019 19:46:49 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9A=90=E8=97=8F=E4=B8=80=E4=B8=AA=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E4=B8=8D=E6=9A=B4=E9=9C=B2=E5=9C=A8.h=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Platform/Win/WinWindow.cpp | 44 +++++++++++++++++----------------- src/Platform/Win/WinWindow.h | 1 - 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/Platform/Win/WinWindow.cpp b/src/Platform/Win/WinWindow.cpp index b636b7fe..2475938c 100644 --- a/src/Platform/Win/WinWindow.cpp +++ b/src/Platform/Win/WinWindow.cpp @@ -2,34 +2,34 @@ namespace hgl { + LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); + namespace { constexpr wchar_t WIN_CLASS_NAME[] = L"CMGameEngine/ULRE Window Class"; - } - LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); + bool RegistryWinClass(HINSTANCE hInstance) + { + WNDCLASSEXW win_class; - bool WinWindow::Registry() - { - WNDCLASSEXW win_class; + hgl_zero(win_class); - hgl_zero(win_class); + win_class.cbSize = sizeof(WNDCLASSEXW); + win_class.style = CS_HREDRAW | CS_VREDRAW; + win_class.lpfnWndProc = WindowProc; + win_class.cbClsExtra = 0; + win_class.cbWndExtra = 0; + win_class.hInstance = hInstance; + win_class.hIcon = LoadIcon(nullptr, IDI_APPLICATION); + win_class.hCursor = LoadCursor(nullptr, IDC_ARROW); + win_class.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); + win_class.lpszMenuName = nullptr; + win_class.lpszClassName = WIN_CLASS_NAME; + win_class.hIconSm = LoadIcon(nullptr, IDI_WINLOGO); - win_class.cbSize = sizeof(WNDCLASSEXW); - win_class.style = CS_HREDRAW | CS_VREDRAW; - win_class.lpfnWndProc = WindowProc; - win_class.cbClsExtra = 0; - win_class.cbWndExtra = 0; - win_class.hInstance = hInstance; - win_class.hIcon = LoadIcon(nullptr, IDI_APPLICATION); - win_class.hCursor = LoadCursor(nullptr, IDC_ARROW); - win_class.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); - win_class.lpszMenuName = nullptr; - win_class.lpszClassName = WIN_CLASS_NAME; - win_class.hIconSm = LoadIcon(nullptr, IDI_WINLOGO); - - return RegisterClassExW(&win_class); - } + return RegisterClassExW(&win_class); + } + }//namespace bool WinWindow::Create() { @@ -99,7 +99,7 @@ namespace hgl hInstance = GetModuleHandleW(nullptr); - if (!Registry()) + if (!RegistryWinClass(hInstance)) return(false); if(!Create()) diff --git a/src/Platform/Win/WinWindow.h b/src/Platform/Win/WinWindow.h index eb05b212..a44656ab 100644 --- a/src/Platform/Win/WinWindow.h +++ b/src/Platform/Win/WinWindow.h @@ -17,7 +17,6 @@ namespace hgl protected: - bool Registry(); bool Create(); void OnClose() override{Close();}