From 8965d2443bcddddcf62c30030af82b07bb9698c6 Mon Sep 17 00:00:00 2001 From: Margen67 Date: Mon, 16 Dec 2024 23:46:37 -0800 Subject: [PATCH] Remove rounded corners on Windows 11 --- projects/cxbx/CMakeLists.txt | 11 ++++++----- src/gui/WndMain.cpp | 6 ++++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/projects/cxbx/CMakeLists.txt b/projects/cxbx/CMakeLists.txt index 01dc847fc5..261edc59cd 100644 --- a/projects/cxbx/CMakeLists.txt +++ b/projects/cxbx/CMakeLists.txt @@ -46,7 +46,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") # Enable Chihiro work CHIHIRO_WORK ) - + # Reference: https://docs.microsoft.com/en-us/cpp/build/reference/compiler-options-listed-alphabetically add_compile_options( # Catch synchronous (C++) exceptions only @@ -68,7 +68,7 @@ XXH_INLINE_ALL ) file (GLOB RESOURCES - + "${CXBXR_ROOT_DIR}/CONTRIBUTORS" "${CXBXR_ROOT_DIR}/COPYING" "${CXBXR_ROOT_DIR}/README.md" @@ -90,7 +90,7 @@ source_group(TREE ${CXBXR_ROOT_DIR}/import PREFIX import FILES ${CXBXR_SOURCE_EMU_IMPORT} ) -source_group(TREE ${CXBXR_ROOT_DIR}/src PREFIX source FILES +source_group(TREE ${CXBXR_ROOT_DIR}/src PREFIX source FILES ${CXBXR_SOURCE_GUIv1} ${CXBXR_SOURCE_COMMON} ) @@ -142,7 +142,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") /Qpar \ " ) - + # disable optimization for CxbxKrnl.cpp file set_source_files_properties( ${CXBXR_KRNL_CPP} PROPERTIES COMPILE_FLAGS "/Od /GL-" @@ -150,7 +150,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") endif() # Windows libraries -set(WINS_LIB +set(WINS_LIB legacy_stdio_definitions d3d9 d3dcompiler @@ -170,6 +170,7 @@ set(WINS_LIB comctl32 XINPUT9_1_0 Iphlpapi + Dwmapi ) target_link_libraries(cxbx diff --git a/src/gui/WndMain.cpp b/src/gui/WndMain.cpp index 6f26b26281..4502c57ecb 100644 --- a/src/gui/WndMain.cpp +++ b/src/gui/WndMain.cpp @@ -56,6 +56,8 @@ #undef GetSystemMetrics // Force remove DirectX 8's multimon.h defined function (redirect to xGetSystemMetrics). #include // For GetSystemMetrics +#include // For DwmSetWindowAttribute + #include #include @@ -323,6 +325,10 @@ LRESULT CALLBACK WndMain::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lP ChangeWindowMessageFilterEx(hwnd, WM_COPYDATA, MSGFLT_ALLOW, nullptr); ChangeWindowMessageFilterEx(hwnd, 0x0049, MSGFLT_ALLOW, nullptr); + // 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)); + m_bCreated = true; } break;