diff --git a/PowerEditor/gcc/makefile b/PowerEditor/gcc/makefile index 31c7104f5..8c8854e7b 100644 --- a/PowerEditor/gcc/makefile +++ b/PowerEditor/gcc/makefile @@ -41,7 +41,7 @@ CXXFLAGS := -include $(GCC_DIRECTORY)/gcc-fixes.h -std=c++20 RC := $(CROSS_COMPILE)windres RCFLAGS := CPP_PATH := $(SCINTILLA_DIRECTORY)/include $(LEXILLA_DIRECTORY)/include -CPP_DEFINE := UNICODE _UNICODE OEMRESOURCE NOMINMAX _WIN32_WINNT=_WIN32_WINNT_WIN7 NTDDI_VERSION=NTDDI_WIN7 TIXML_USE_STL TIXMLA_USE_STL +CPP_DEFINE := UNICODE _UNICODE OEMRESOURCE NOMINMAX _WIN32_WINNT=_WIN32_WINNT_WIN10 NTDDI_VERSION=NTDDI_WIN10_RS5 TIXML_USE_STL TIXMLA_USE_STL LD := $(CXX) LDFLAGS := -municode -mwindows LD_PATH := diff --git a/PowerEditor/src/CMakeLists.txt b/PowerEditor/src/CMakeLists.txt index e1f69e43d..3297d4549 100644 --- a/PowerEditor/src/CMakeLists.txt +++ b/PowerEditor/src/CMakeLists.txt @@ -395,13 +395,13 @@ IF (WIN32) if ( MSVC ) #do not use for mingw builds SET(CMAKE_CXX_FLAGS "/EHa /MP /W4") - SET(defs -DUNICODE -D_UNICODE -D_WIN32_WINNT=_WIN32_WINNT_WIN7 -DNTDDI_VERSION=NTDDI_WIN7 -D_USE_64BIT_TIME_T -DTIXML_USE_STL -DTIXMLA_USE_STL -DNOMINMAX -DOEMRESOURCE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING ) + SET(defs -DUNICODE -D_UNICODE -D_WIN32_WINNT=_WIN32_WINNT_WIN10 -DNTDDI_VERSION=NTDDI_WIN10_RS5 -D_USE_64BIT_TIME_T -DTIXML_USE_STL -DTIXMLA_USE_STL -DNOMINMAX -DOEMRESOURCE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING ) set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd") else ( MSVC ) # For possible MinGW compilation SET(CMAKE_CXX_FLAGS "-include../gcc/gcc-fixes.h -std=c++20 -fpermissive -municode") - SET(defs -DUNICODE -D_UNICODE -D_WIN32_WINNT=_WIN32_WINNT_WIN7 -DNTDDI_VERSION=NTDDI_WIN7 -D_USE_64BIT_TIME_T -DTIXML_USE_STL -DTIXMLA_USE_STL -DNOMINMAX -DOEMRESOURCE) + SET(defs -DUNICODE -D_UNICODE -D_WIN32_WINNT=_WIN32_WINNT_WIN10 -DNTDDI_VERSION=NTDDI_WIN10_RS5 -D_USE_64BIT_TIME_T -DTIXML_USE_STL -DTIXMLA_USE_STL -DNOMINMAX -DOEMRESOURCE) endif ( MSVC ) ENDIF (WIN32) diff --git a/PowerEditor/src/NppDarkMode.cpp b/PowerEditor/src/NppDarkMode.cpp index 75f5693ed..56b8c085b 100644 --- a/PowerEditor/src/NppDarkMode.cpp +++ b/PowerEditor/src/NppDarkMode.cpp @@ -1600,10 +1600,20 @@ namespace NppDarkMode void setMetricsForDpi(UINT dpi) { _dpi = dpi; - _xEdge = DPIManagerV2::getSystemMetricsForDpi(SM_CXEDGE, _dpi); - _yEdge = DPIManagerV2::getSystemMetricsForDpi(SM_CYEDGE, _dpi); - _xScroll = DPIManagerV2::getSystemMetricsForDpi(SM_CXVSCROLL, _dpi); - _yScroll = DPIManagerV2::getSystemMetricsForDpi(SM_CYVSCROLL, _dpi); + if (NppDarkMode::isWindows10()) + { + _xEdge = ::GetSystemMetricsForDpi(SM_CXEDGE, _dpi); + _yEdge = ::GetSystemMetricsForDpi(SM_CYEDGE, _dpi); + _xScroll = ::GetSystemMetricsForDpi(SM_CXVSCROLL, _dpi); + _yScroll = ::GetSystemMetricsForDpi(SM_CYVSCROLL, _dpi); + } + else + { + _xEdge = DPIManagerV2::scale(::GetSystemMetrics(SM_CXEDGE), _dpi); + _yEdge = DPIManagerV2::scale(::GetSystemMetrics(SM_CYEDGE), _dpi); + _xScroll = DPIManagerV2::scale(::GetSystemMetrics(SM_CXVSCROLL), _dpi); + _yScroll = DPIManagerV2::scale(::GetSystemMetrics(SM_CYVSCROLL), _dpi); + } } }; diff --git a/PowerEditor/src/dpiManagerV2.cpp b/PowerEditor/src/dpiManagerV2.cpp index c92bb65c0..86d25be5a 100644 --- a/PowerEditor/src/dpiManagerV2.cpp +++ b/PowerEditor/src/dpiManagerV2.cpp @@ -17,54 +17,11 @@ #include "dpiManagerV2.h" -template -bool ptrFn(HMODULE handle, P& pointer, const char* name) -{ - auto p = reinterpret_cast

(::GetProcAddress(handle, name)); - if (p != nullptr) - { - pointer = p; - return true; - } - return false; -} - -using fnGetDpiForSystem = UINT (WINAPI*)(); -using fnGetDpiForWindow = UINT (WINAPI*)(HWND); -using fnGetSystemMetricsForDpi = int (WINAPI*)(int, UINT); -using fnSystemParametersInfoForDpi = BOOL(WINAPI*)(UINT, UINT, PVOID, UINT, UINT); - -fnGetDpiForSystem _fnGetDpiForSystem = nullptr; -fnGetDpiForWindow _fnGetDpiForWindow = nullptr; -fnGetSystemMetricsForDpi _fnGetSystemMetricsForDpi = nullptr; -fnSystemParametersInfoForDpi _fnSystemParametersInfoForDpi = nullptr; - -void DPIManagerV2::initDpiAPI() -{ - HMODULE hUser32 = ::GetModuleHandleW(L"user32.dll"); - if (hUser32) - { - ptrFn(hUser32, _fnGetDpiForSystem, "GetDpiForSystem"); - ptrFn(hUser32, _fnGetDpiForWindow, "GetDpiForWindow"); - ptrFn(hUser32, _fnGetSystemMetricsForDpi, "GetSystemMetricsForDpi"); - ptrFn(hUser32, _fnSystemParametersInfoForDpi, "SystemParametersInfoForDpi"); - } -} - -int DPIManagerV2::getSystemMetricsForDpi(int nIndex, UINT dpi) -{ - if (_fnGetSystemMetricsForDpi != nullptr) - { - return _fnGetSystemMetricsForDpi(nIndex, dpi); - } - return DPIManagerV2::scale(::GetSystemMetrics(nIndex), dpi); -} - UINT DPIManagerV2::getDpiForSystem() { - if (_fnGetDpiForSystem != nullptr) + if (NppDarkMode::isWindows10()) { - return _fnGetDpiForSystem(); + return ::GetDpiForSystem(); } UINT dpi = USER_DEFAULT_SCREEN_DPI; @@ -79,9 +36,9 @@ UINT DPIManagerV2::getDpiForSystem() UINT DPIManagerV2::getDpiForWindow(HWND hWnd) { - if (_fnGetDpiForWindow != nullptr) + if (NppDarkMode::isWindows10()) { - const auto dpi = _fnGetDpiForWindow(hWnd); + const auto dpi = ::GetDpiForWindow(hWnd); if (dpi > 0) { return dpi; @@ -109,8 +66,8 @@ LOGFONT DPIManagerV2::getDefaultGUIFontForDpi(UINT dpi, FontType type) LOGFONT lf{}; NONCLIENTMETRICS ncm{}; ncm.cbSize = sizeof(NONCLIENTMETRICS); - if (_fnSystemParametersInfoForDpi != nullptr - && (_fnSystemParametersInfoForDpi(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0, dpi) != FALSE)) + if (NppDarkMode::isWindows10() + && (::SystemParametersInfoForDpi(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0, dpi) != FALSE)) { result = 2; } diff --git a/PowerEditor/src/dpiManagerV2.h b/PowerEditor/src/dpiManagerV2.h index b1f6e1e81..c24968272 100644 --- a/PowerEditor/src/dpiManagerV2.h +++ b/PowerEditor/src/dpiManagerV2.h @@ -16,7 +16,7 @@ #pragma once -#include +#include "NppDarkMode.h" class DPIManagerV2 { @@ -28,10 +28,6 @@ public: enum class FontType { menu, status, message, caption, smcaption }; - static void initDpiAPI(); - - static int getSystemMetricsForDpi(int nIndex, UINT dpi); - static UINT getDpiForSystem(); static UINT getDpiForWindow(HWND hWnd); static UINT getDpiForParent(HWND hWnd) { diff --git a/PowerEditor/src/winmain.cpp b/PowerEditor/src/winmain.cpp index f1db98ebf..66401d6f2 100644 --- a/PowerEditor/src/winmain.cpp +++ b/PowerEditor/src/winmain.cpp @@ -20,7 +20,6 @@ #include "MiniDumper.h" //Write dump files #include "verifySignedfile.h" #include "NppDarkMode.h" -#include "dpiManagerV2.h" #include typedef std::vector ParamVector; @@ -503,7 +502,6 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE /*hPrevInstance NppGUI & nppGui = nppParameters.getNppGUI(); NppDarkMode::initDarkMode(); - DPIManagerV2::initDpiAPI(); bool doUpdateNpp = nppGui._autoUpdateOpt._doAutoUpdate; bool doUpdatePluginList = nppGui._autoUpdateOpt._doAutoUpdate; diff --git a/PowerEditor/visual.net/notepadPlus.Cpp.props b/PowerEditor/visual.net/notepadPlus.Cpp.props index 526604586..f3fbd9e8b 100644 --- a/PowerEditor/visual.net/notepadPlus.Cpp.props +++ b/PowerEditor/visual.net/notepadPlus.Cpp.props @@ -25,7 +25,7 @@ ..\src;..\src\MISC;..\src\MISC\Common;..\src\MISC\Exception;..\src\MISC\PluginsManager;..\src\MISC\Process;..\src\MISC\RegExt;..\src\MISC\md5;..\src\MISC\sha1;..\src\MISC\sha2;..\src\MISC\sha512;..\src\MISC\SysMsg;..\src\ScintillaComponent;..\src\Win32Explr;..\src\WinControls;..\src\WinControls\AboutDlg;..\src\WinControls\AnsiCharPanel;..\src\WinControls\ClipboardHistory;..\src\WinControls\ColourPicker;..\src\WinControls\ContextMenu;..\src\WinControls\DockingWnd;..\src\WinControls\DocumentMap;..\src\WinControls\FileBrowser;..\src\WinControls\FindCharsInRange;..\src\WinControls\FunctionList;..\src\WinControls\Grid;..\src\WinControls\ImageListSet;..\src\WinControls\OpenSaveFileDialog;..\src\WinControls\PluginsAdmin;..\src\WinControls\Preference;..\src\WinControls\ProjectPanel;..\src\WinControls\ReadDirectoryChanges;..\src\WinControls\shortcut;..\src\WinControls\SplitterContainer;..\src\WinControls\StaticDialog;..\src\WinControls\StaticDialog\RunDlg;..\src\WinControls\StatusBar;..\src\WinControls\TabBar;..\src\WinControls\TaskList;..\src\WinControls\ToolBar;..\src\WinControls\ToolTip;..\src\WinControls\TrayIcon;..\src\WinControls\TreeView;..\src\WinControls\VerticalFileSwitcher;..\src\WinControls\WindowsDlg;%(AdditionalIncludeDirectories) - WIN32;_WIN32_WINNT=_WIN32_WINNT_WIN7;NTDDI_VERSION=NTDDI_WIN7;_WINDOWS;OEMRESOURCE;NOMINMAX;_USE_64BIT_TIME_T;TIXML_USE_STL;TIXMLA_USE_STL;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;%(PreprocessorDefinitions) + WIN32;_WIN32_WINNT=_WIN32_WINNT_WIN10;NTDDI_VERSION=NTDDI_WIN10_RS5;_WINDOWS;OEMRESOURCE;NOMINMAX;_USE_64BIT_TIME_T;TIXML_USE_STL;TIXMLA_USE_STL;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;%(PreprocessorDefinitions) Async Level4 true