diff --git a/src/gui/WndMain.cpp b/src/gui/WndMain.cpp index f558cb88ec..2503bd9921 100644 --- a/src/gui/WndMain.cpp +++ b/src/gui/WndMain.cpp @@ -259,16 +259,19 @@ LRESULT CALLBACK WndMain::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lP { case WM_CREATE: { - // Remove rounded corners from the render window on Windows 11 - const DWM_WINDOW_CORNER_PREFERENCE corner_preference = DWMWCP_DONOTROUND; - DwmSetWindowAttribute(hwnd, DWMWA_WINDOW_CORNER_PREFERENCE, &corner_preference, - sizeof(corner_preference)); - // initialize menu - { - HMENU hMenu = LoadMenu(m_hInstance, MAKEINTRESOURCE(IDR_MAINMENU)); + if (hwnd) + { + // Remove rounded corners from the render window on Windows 11 + const DWM_WINDOW_CORNER_PREFERENCE corner_preference = DWMWCP_DONOTROUND; + DwmSetWindowAttribute(hwnd, DWMWA_WINDOW_CORNER_PREFERENCE, &corner_preference, + sizeof(corner_preference)); + // initialize menu + { + HMENU hMenu = LoadMenu(m_hInstance, MAKEINTRESOURCE(IDR_MAINMENU)); - SetMenu(hwnd, hMenu); - } + SetMenu(hwnd, hMenu); + } + } // Set window size to GUI dimensions ResizeWindow(hwnd, /*bForGUI=*/true);