diff --git a/PowerEditor/gcc/makefile b/PowerEditor/gcc/makefile index 1e3f2a34c..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_VISTA 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 02365bd51..3297d4549 100644 --- a/PowerEditor/src/CMakeLists.txt +++ b/PowerEditor/src/CMakeLists.txt @@ -74,6 +74,7 @@ SET(src_files ./MISC/sha2/sha-256.cpp ./MISC/sha512/sha512.cpp ./NppDarkMode.cpp + ./dpiManagerV2.cpp ./MISC/Process/Processus.cpp ./WinControls/AboutDlg/AboutDlg.cpp ./WinControls/AnsiCharPanel/ansiCharPanel.cpp @@ -203,6 +204,7 @@ SET(include_files ./DarkMode/IatHook.h ./DarkMode/UAHMenuBar.h ./dpiManager.h + ./dpiManagerV2.h ./keys.h ./localizationString.h ./MISC/Common/Sorters.h @@ -393,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_VISTA -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_VISTA -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 27b57c787..56b8c085b 100644 --- a/PowerEditor/src/NppDarkMode.cpp +++ b/PowerEditor/src/NppDarkMode.cpp @@ -26,6 +26,7 @@ #include "Parameters.h" #include "resource.h" +#include "dpiManagerV2.h" #include @@ -48,7 +49,7 @@ //#pragma comment(lib, "uxtheme.lib") //#endif -constexpr COLORREF HEXRGB(DWORD rrggbb) { +static constexpr COLORREF HEXRGB(DWORD rrggbb) { // from 0xRRGGBB like natural #RRGGBB // to the little-endian 0xBBGGRR return @@ -1001,7 +1002,7 @@ namespace NppDarkMode } }; - void renderButton(HWND hwnd, HDC hdc, HTHEME hTheme, int iPartID, int iStateID) + static void renderButton(HWND hwnd, HDC hdc, HTHEME hTheme, int iPartID, int iStateID) { RECT rcClient{}; WCHAR szText[256] = { '\0' }; @@ -1085,7 +1086,7 @@ namespace NppDarkMode SelectObject(hdc, hOldFont); } - void paintButton(HWND hwnd, HDC hdc, ButtonData& buttonData) + static void paintButton(HWND hwnd, HDC hdc, ButtonData& buttonData) { DWORD nState = static_cast(SendMessage(hwnd, BM_GETSTATE, 0, 0)); const auto nStyle = GetWindowLongPtr(hwnd, GWL_STYLE); @@ -1160,7 +1161,7 @@ namespace NppDarkMode constexpr UINT_PTR g_buttonSubclassID = 42; - LRESULT CALLBACK ButtonSubclass( + static LRESULT CALLBACK ButtonSubclass( HWND hWnd, UINT uMsg, WPARAM wParam, @@ -1185,18 +1186,28 @@ namespace NppDarkMode RemoveWindowSubclass(hWnd, ButtonSubclass, g_buttonSubclassID); delete pButtonData; break; + case WM_ERASEBKGND: + { if (NppDarkMode::isEnabled() && pButtonData->ensureTheme(hWnd)) { return TRUE; } - else - { - break; - } + break; + } + + case WM_DPICHANGED: + { + pButtonData->closeTheme(); + return 0; + } + case WM_THEMECHANGED: + { pButtonData->closeTheme(); break; + } + case WM_PRINTCLIENT: case WM_PAINT: if (NppDarkMode::isEnabled() && pButtonData->ensureTheme(hWnd)) @@ -1244,7 +1255,7 @@ namespace NppDarkMode SetWindowSubclass(hwnd, ButtonSubclass, g_buttonSubclassID, pButtonData); } - void paintGroupbox(HWND hwnd, HDC hdc, ButtonData& buttonData) + static void paintGroupbox(HWND hwnd, HDC hdc, ButtonData& buttonData) { auto nStyle = ::GetWindowLongPtr(hwnd, GWL_STYLE); bool isDisabled = (nStyle & WS_DISABLED) == WS_DISABLED; @@ -1337,7 +1348,7 @@ namespace NppDarkMode constexpr UINT_PTR g_groupboxSubclassID = 42; - LRESULT CALLBACK GroupboxSubclass( + static LRESULT CALLBACK GroupboxSubclass( HWND hWnd, UINT uMsg, WPARAM wParam, @@ -1356,18 +1367,28 @@ namespace NppDarkMode RemoveWindowSubclass(hWnd, GroupboxSubclass, g_groupboxSubclassID); delete pButtonData; break; + case WM_ERASEBKGND: + { if (NppDarkMode::isEnabled() && pButtonData->ensureTheme(hWnd)) { return TRUE; } - else - { - break; - } + break; + } + + case WM_DPICHANGED: + { + pButtonData->closeTheme(); + return 0; + } + case WM_THEMECHANGED: + { pButtonData->closeTheme(); break; + } + case WM_PRINTCLIENT: case WM_PAINT: if (NppDarkMode::isEnabled() && pButtonData->ensureTheme(hWnd)) @@ -1388,10 +1409,6 @@ namespace NppDarkMode return 0; } - else - { - break; - } break; } return DefSubclassProc(hWnd, uMsg, wParam, lParam); @@ -1405,7 +1422,7 @@ namespace NppDarkMode constexpr UINT_PTR g_tabSubclassID = 42; - LRESULT CALLBACK TabSubclass( + static LRESULT CALLBACK TabSubclass( HWND hWnd, UINT uMsg, WPARAM wParam, @@ -1492,15 +1509,15 @@ namespace NppDarkMode ::SendMessage(hWnd, TCM_GETITEM, i, reinterpret_cast(&tci)); - auto dpiManager = NppParameters::getInstance()._dpiManager; + const auto dpi = DPIManagerV2::getDpiForParent(hWnd); RECT rcText = rcItem; - rcText.left += dpiManager.scaleX(5); - rcText.right -= dpiManager.scaleX(3); + rcText.left += DPIManagerV2::scale(5, dpi); + rcText.right -= DPIManagerV2::scale(3, dpi); if (isSelectedTab) { - rcText.bottom -= dpiManager.scaleY(4); + rcText.bottom -= DPIManagerV2::scale(4, dpi); ::InflateRect(&rcFrame, 0, 1); } if (i != nTabs - 1) @@ -1565,9 +1582,44 @@ namespace NppDarkMode SetWindowSubclass(hwnd, TabSubclass, g_tabSubclassID, 0); } + struct BorderMetricsData + { + UINT _dpi = USER_DEFAULT_SCREEN_DPI; + LONG _xEdge = ::GetSystemMetrics(SM_CXEDGE); + LONG _yEdge = ::GetSystemMetrics(SM_CYEDGE); + LONG _xScroll = ::GetSystemMetrics(SM_CXVSCROLL); + LONG _yScroll = ::GetSystemMetrics(SM_CYVSCROLL); + + BorderMetricsData() {}; + + BorderMetricsData(HWND hWnd) + { + setMetricsForDpi(DPIManagerV2::getDpiForParent(hWnd)); + } + + void setMetricsForDpi(UINT dpi) + { + _dpi = 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); + } + } + }; + constexpr UINT_PTR g_customBorderSubclassID = 42; - LRESULT CALLBACK CustomBorderSubclass( + static LRESULT CALLBACK CustomBorderSubclass( HWND hWnd, UINT uMsg, WPARAM wParam, @@ -1576,7 +1628,7 @@ namespace NppDarkMode DWORD_PTR dwRefData ) { - UNREFERENCED_PARAMETER(dwRefData); + auto pBorderMetricsData = reinterpret_cast(dwRefData); static bool isHotStatic = false; @@ -1594,21 +1646,21 @@ namespace NppDarkMode HDC hdc = ::GetWindowDC(hWnd); RECT rcClient{}; ::GetClientRect(hWnd, &rcClient); - rcClient.right += (2 * ::GetSystemMetrics(SM_CXEDGE)); + rcClient.right += (2 * pBorderMetricsData->_xEdge); auto style = ::GetWindowLongPtr(hWnd, GWL_STYLE); bool hasVerScrollbar = (style & WS_VSCROLL) == WS_VSCROLL; if (hasVerScrollbar) { - rcClient.right += ::GetSystemMetrics(SM_CXVSCROLL); + rcClient.right += pBorderMetricsData->_xScroll; } - rcClient.bottom += (2 * ::GetSystemMetrics(SM_CYEDGE)); + rcClient.bottom += (2 * pBorderMetricsData->_yEdge); bool hasHorScrollbar = (style & WS_HSCROLL) == WS_HSCROLL; if (hasHorScrollbar) { - rcClient.bottom += ::GetSystemMetrics(SM_CYHSCROLL); + rcClient.bottom += pBorderMetricsData->_yScroll; } HPEN hPen = ::CreatePen(PS_SOLID, 1, NppDarkMode::getBackgroundColor()); @@ -1644,25 +1696,32 @@ namespace NppDarkMode } auto lpRect = reinterpret_cast(lParam); - ::InflateRect(lpRect, -(::GetSystemMetrics(SM_CXEDGE)), -(::GetSystemMetrics(SM_CYEDGE))); + ::InflateRect(lpRect, -(pBorderMetricsData->_xEdge), -(pBorderMetricsData->_yEdge)); auto style = ::GetWindowLongPtr(hWnd, GWL_STYLE); bool hasVerScrollbar = (style & WS_VSCROLL) == WS_VSCROLL; if (hasVerScrollbar) { - lpRect->right -= ::GetSystemMetrics(SM_CXVSCROLL); + lpRect->right -= pBorderMetricsData->_xScroll; } bool hasHorScrollbar = (style & WS_HSCROLL) == WS_HSCROLL; if (hasHorScrollbar) { - lpRect->bottom -= ::GetSystemMetrics(SM_CYHSCROLL); + lpRect->bottom -= pBorderMetricsData->_yScroll; } return 0; } break; + case WM_DPICHANGED: + { + pBorderMetricsData->setMetricsForDpi(LOWORD(wParam)); + ::SetWindowPos(hWnd, nullptr, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); + return 0; + } + case WM_MOUSEMOVE: { if (!NppDarkMode::isEnabled()) @@ -1715,20 +1774,22 @@ namespace NppDarkMode case WM_NCDESTROY: { RemoveWindowSubclass(hWnd, CustomBorderSubclass, uIdSubclass); + delete pBorderMetricsData; } break; } return DefSubclassProc(hWnd, uMsg, wParam, lParam); } - void subclassCustomBorderForListBoxAndEditControls(HWND hwnd) + static void subclassCustomBorderForListBoxAndEditControls(HWND hwnd) { - SetWindowSubclass(hwnd, CustomBorderSubclass, g_customBorderSubclassID, 0); + auto pBorderMetricsData = reinterpret_cast(new BorderMetricsData(hwnd)); + SetWindowSubclass(hwnd, CustomBorderSubclass, g_customBorderSubclassID, pBorderMetricsData); } constexpr UINT_PTR g_comboBoxSubclassID = 42; - LRESULT CALLBACK ComboBoxSubclass( + static LRESULT CALLBACK ComboBoxSubclass( HWND hWnd, UINT uMsg, WPARAM wParam, @@ -1759,7 +1820,7 @@ namespace NppDarkMode auto holdBrush = ::SelectObject(hdc, NppDarkMode::getDarkerBackgroundBrush()); - auto& dpiManager = NppParameters::getInstance()._dpiManager; + const auto dpi = DPIManagerV2::getDpiForParent(hWnd); RECT rcArrow{}; @@ -1774,7 +1835,7 @@ namespace NppDarkMode else { rcArrow = { - rc.right - dpiManager.scaleX(17), rc.top + 1, + rc.right - DPIManagerV2::scale(17, dpi), rc.top + 1, rc.right - 1, rc.bottom - 1 }; } @@ -1857,7 +1918,7 @@ namespace NppDarkMode }; ::Polyline(hdc, edge, _countof(edge)); - int roundCornerValue = NppDarkMode::isWindows11() ? dpiManager.scaleX(4) : 0; + const int roundCornerValue = NppDarkMode::isWindows11() ? DPIManagerV2::scale(4, dpi) : 0; NppDarkMode::paintRoundFrameRect(hdc, rc, hSelectedPen, roundCornerValue, roundCornerValue); ::SelectObject(hdc, holdPen); @@ -1954,7 +2015,7 @@ namespace NppDarkMode constexpr UINT_PTR g_upDownSubclassID = 42; - LRESULT CALLBACK UpDownSubclass( + static LRESULT CALLBACK UpDownSubclass( HWND hWnd, UINT uMsg, WPARAM wParam, @@ -2060,6 +2121,12 @@ namespace NppDarkMode return FALSE; } + case WM_DPICHANGED: + { + pButtonData->closeTheme(); + return 0; + } + case WM_THEMECHANGED: { pButtonData->closeTheme(); @@ -2088,7 +2155,7 @@ namespace NppDarkMode return DefSubclassProc(hWnd, uMsg, wParam, lParam); } - void subclassAndThemeUpDownControl(HWND hwnd, NppDarkModeParams p) + static void subclassAndThemeUpDownControl(HWND hwnd, NppDarkModeParams p) { if (p._subclass) { @@ -2415,8 +2482,12 @@ namespace NppDarkMode { if (NppDarkMode::isEnabled()) { - auto dpiManager = NppParameters::getInstance()._dpiManager; - roundCornerValue = NppDarkMode::isWindows11() ? dpiManager.scaleX(5) : 0; + if (NppDarkMode::isWindows11()) + { + const auto nmhdr = reinterpret_cast(lParam); + const auto dpi = DPIManagerV2::getDpiForParent(nmhdr->hwndFrom); + roundCornerValue = DPIManagerV2::scale(5, dpi); + } ::FillRect(nmtbcd->nmcd.hdc, &nmtbcd->nmcd.rc, NppDarkMode::getDarkerBackgroundBrush()); return CDRF_NOTIFYITEMDRAW; diff --git a/PowerEditor/src/dpiAware.manifest b/PowerEditor/src/dpiAware.manifest index da6fae4f6..97fd51443 100644 --- a/PowerEditor/src/dpiAware.manifest +++ b/PowerEditor/src/dpiAware.manifest @@ -1,9 +1,14 @@ - - - true - - + + + true + + + system, unaware + + + false + + \ No newline at end of file diff --git a/PowerEditor/src/dpiManagerV2.cpp b/PowerEditor/src/dpiManagerV2.cpp new file mode 100644 index 000000000..86d25be5a --- /dev/null +++ b/PowerEditor/src/dpiManagerV2.cpp @@ -0,0 +1,126 @@ +// This file is part of Notepad++ project +// Copyright (c) 2024 ozone10 and Notepad++ team + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + + +#include "dpiManagerV2.h" + +UINT DPIManagerV2::getDpiForSystem() +{ + if (NppDarkMode::isWindows10()) + { + return ::GetDpiForSystem(); + } + + UINT dpi = USER_DEFAULT_SCREEN_DPI; + HDC hdc = ::GetDC(nullptr); + if (hdc != nullptr) + { + dpi = ::GetDeviceCaps(hdc, LOGPIXELSX); + ::ReleaseDC(nullptr, hdc); + } + return dpi; +} + +UINT DPIManagerV2::getDpiForWindow(HWND hWnd) +{ + if (NppDarkMode::isWindows10()) + { + const auto dpi = ::GetDpiForWindow(hWnd); + if (dpi > 0) + { + return dpi; + } + } + return getDpiForSystem(); +} + +void DPIManagerV2::setPositionDpi(LPARAM lParam, HWND hWnd) +{ + const auto prcNewWindow = reinterpret_cast(lParam); + + ::SetWindowPos(hWnd, + nullptr, + prcNewWindow->left, + prcNewWindow->top, + prcNewWindow->right - prcNewWindow->left, + prcNewWindow->bottom - prcNewWindow->top, + SWP_NOZORDER | SWP_NOACTIVATE); +} + +LOGFONT DPIManagerV2::getDefaultGUIFontForDpi(UINT dpi, FontType type) +{ + int result = 0; + LOGFONT lf{}; + NONCLIENTMETRICS ncm{}; + ncm.cbSize = sizeof(NONCLIENTMETRICS); + if (NppDarkMode::isWindows10() + && (::SystemParametersInfoForDpi(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0, dpi) != FALSE)) + { + result = 2; + } + else if (::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0) != FALSE) + { + result = 1; + } + + if (result > 0) + { + switch (type) + { + case FontType::menu: + { + lf = ncm.lfMenuFont; + break; + } + + case FontType::status: + { + lf = ncm.lfStatusFont; + break; + } + + case FontType::caption: + { + lf = ncm.lfCaptionFont; + break; + } + + case FontType::smcaption: + { + lf = ncm.lfSmCaptionFont; + break; + } + //case FontType::message: + default: + { + lf = ncm.lfMessageFont; + break; + } + } + } + else // should not happen, fallback + { + auto hf = static_cast(::GetStockObject(DEFAULT_GUI_FONT)); + ::GetObject(hf, sizeof(LOGFONT), &lf); + } + + if (result < 2) + { + lf.lfHeight = scaleFont(lf.lfHeight, dpi); + } + + return lf; +} diff --git a/PowerEditor/src/dpiManagerV2.h b/PowerEditor/src/dpiManagerV2.h new file mode 100644 index 000000000..c24968272 --- /dev/null +++ b/PowerEditor/src/dpiManagerV2.h @@ -0,0 +1,115 @@ +// This file is part of Notepad++ project +// Copyright (c) 2024 ozone10 and Notepad++ team + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + + +#pragma once +#include "NppDarkMode.h" + +class DPIManagerV2 +{ +public: + DPIManagerV2() { + setDpiWithSystem(); + } + virtual ~DPIManagerV2() = default; + + enum class FontType { menu, status, message, caption, smcaption }; + + static UINT getDpiForSystem(); + static UINT getDpiForWindow(HWND hWnd); + static UINT getDpiForParent(HWND hWnd) { + return getDpiForWindow(::GetParent(hWnd)); + } + + void setDpiWithSystem() { + _dpi = getDpiForSystem(); + } + + // parameter is WPARAM + void setDpiWP(WPARAM wParam) { + _dpi = LOWORD(wParam); + } + + void setDpi(UINT newDpi) { + _dpi = newDpi; + } + + void setDpi(HWND hWnd) { + setDpi(getDpiForWindow(hWnd)); + } + + void setDpiWithParent(HWND hWnd) { + setDpi(::GetParent(hWnd)); + } + + UINT getDpi() const { + return _dpi; + } + + static void setPositionDpi(LPARAM lParam, HWND hWnd); + + static int scale(int x, UINT dpi, UINT dpi2) { + return MulDiv(x, dpi, dpi2); + } + + static int scale(int x, UINT dpi) { + return scale(x, dpi, USER_DEFAULT_SCREEN_DPI); + } + + static int unscale(int x, UINT dpi) { + return scale(x, USER_DEFAULT_SCREEN_DPI, dpi); + } + + int scale(int x) { + return scale(x, _dpi); + } + + int unscale(int x) { + return unscale(x, _dpi); + } + + int scaleX(int x) { + return scale(x); + } + + int unscaleX(int x) { + return unscale(x); + } + + int scaleY(int y) { + return scale(y); + } + + int unscaleY(int y) { + return unscale(y); + } + + static int scaleFont(int pt, UINT dpi) { + return -(scale(pt, dpi, 72)); + } + + int scaleFont(int pt) { + return scaleFont(pt, _dpi); + } + + static LOGFONT getDefaultGUIFontForDpi(UINT dpi, FontType type = FontType::message); + static LOGFONT getDefaultGUIFontForDpi(HWND hWnd, FontType type = FontType::message) { + return getDefaultGUIFontForDpi(getDpiForWindow(hWnd), type); + } + +private: + UINT _dpi = USER_DEFAULT_SCREEN_DPI; +}; diff --git a/PowerEditor/visual.net/notepadPlus.Cpp.props b/PowerEditor/visual.net/notepadPlus.Cpp.props index 26609f63a..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_VISTA;_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 diff --git a/PowerEditor/visual.net/notepadPlus.vcxproj b/PowerEditor/visual.net/notepadPlus.vcxproj index 97517da0b..d149a2510 100755 --- a/PowerEditor/visual.net/notepadPlus.vcxproj +++ b/PowerEditor/visual.net/notepadPlus.vcxproj @@ -114,6 +114,7 @@ + @@ -242,6 +243,7 @@ +