Skip to content

Commit a4b7b1e

Browse files
committed
Add HiDPI support in Windows
1 parent b34b683 commit a4b7b1e

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

prj/NAppTarget.cmake

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -386,11 +386,9 @@ function(nap_resource_packs targetName targetType nrcMode dir _resFiles _resIncl
386386
endif()
387387

388388
# Reference the manifest file (required by MinGW)
389-
if (NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
390-
# https://geekthis.net/post/visual-styles-in-win32-api-c-gcc-mingw/
391-
set(MANIFEST_FILE "${NAPPGUI_ROOT_PATH}/prj/templates/Application.manifest")
392-
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/res.rc "1 24 \"${MANIFEST_FILE}\"\n")
393-
endif()
389+
# https://geekthis.net/post/visual-styles-in-win32-api-c-gcc-mingw/
390+
set(MANIFEST_FILE "${NAPPGUI_ROOT_PATH}/prj/templates/Application.manifest")
391+
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/res.rc "1 24 \"${MANIFEST_FILE}\"\n")
394392

395393
set(globalRes ${globalRes} ${CMAKE_CURRENT_BINARY_DIR}/res.rc)
396394
endif()
@@ -797,6 +795,11 @@ function(nap_link_with_libraries targetName targetType firstLevelDepends)
797795
target_link_libraries(${targetName} comctl32 uxtheme)
798796
endif()
799797

798+
# Disable default MSVC manifest
799+
if (${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
800+
target_link_options(${targetName} PRIVATE /MANIFEST:NO)
801+
endif()
802+
800803
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
801804
# Target should link with math always
802805
target_link_libraries(${targetName} "m")

prj/templates/Application.manifest

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2-
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
2+
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" manifestVersion="1.0">
33
<assemblyIdentity version="1.0.0.0" processorArchitecture="*" name="nappgui.application" type="win32" />
44
<description>Your application description here.</description>
55
<dependency>
66
<dependentAssembly>
77
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*" />
88
</dependentAssembly>
99
</dependency>
10-
</assembly>
10+
<asmv3:application>
11+
<asmv3:windowsSettings>
12+
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
13+
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
14+
</asmv3:windowsSettings>
15+
</asmv3:application>
16+
</assembly>

0 commit comments

Comments
 (0)