From 79acd5d11041ad998c6a8296c295d35b340b9883 Mon Sep 17 00:00:00 2001 From: dreamforceinc Date: Mon, 28 Feb 2022 19:32:46 +0300 Subject: [PATCH] Moved RegisterClass function into WinMain. --- wCenterWindow/wCenterWindow.cpp | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/wCenterWindow/wCenterWindow.cpp b/wCenterWindow/wCenterWindow.cpp index eb6c9a9..92d5006 100644 --- a/wCenterWindow/wCenterWindow.cpp +++ b/wCenterWindow/wCenterWindow.cpp @@ -99,20 +99,6 @@ VOID MoveWindowToMonitorCenter(HWND hwnd, BOOL bWorkArea, BOOL bResize) } -ATOM MyRegisterClass(HINSTANCE hInstance) -{ - WNDCLASSEX wcex = { 0 }; - wcex.cbSize = sizeof(WNDCLASSEX); - wcex.lpfnWndProc = WndProc; - wcex.hInstance = hInstance; - wcex.hIcon = LoadIconW(hInstance, MAKEINTRESOURCE(IDI_TRAYICON)); - wcex.hCursor = LoadCursorW(nullptr, IDC_ARROW); - wcex.lpszClassName = szClass; - wcex.hIconSm = wcex.hIcon; - hIcon = wcex.hIcon; - return RegisterClassExW(&wcex); -} - int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) { @@ -130,7 +116,16 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd OpenLogFile(); diag_log("Entering WinMain()"); - MyRegisterClass(hInstance); + WNDCLASSEX wcex = { 0 }; + wcex.cbSize = sizeof(WNDCLASSEX); + wcex.lpfnWndProc = WndProc; + wcex.hInstance = hInstance; + wcex.hIcon = LoadIconW(hInstance, MAKEINTRESOURCE(IDI_TRAYICON)); + wcex.hCursor = LoadCursorW(nullptr, IDC_ARROW); + wcex.lpszClassName = szClass; + wcex.hIconSm = wcex.hIcon; + hIcon = wcex.hIcon; + hWnd = CreateWindowExW(0, szClass, szTitle, 0, 0, 0, 0, 0, NULL, NULL, hInstance, NULL); if (!hWnd) {