From 999b4d18877c3baa6e4a1b33bf8301e0b884a76f Mon Sep 17 00:00:00 2001 From: Don Ho Date: Sun, 17 Mar 2024 16:26:54 +0100 Subject: [PATCH] Revert "Improve hiDPI appearance for some DM elements" This reverts commit 356d5cd072b25f941266f40ea93118f274affdd9. Close #14875 --- PowerEditor/gcc/makefile | 2 +- PowerEditor/src/CMakeLists.txt | 6 +- PowerEditor/src/NppDarkMode.cpp | 155 +++++-------------- PowerEditor/src/dpiAware.manifest | 17 +- PowerEditor/src/dpiManagerV2.cpp | 126 --------------- PowerEditor/src/dpiManagerV2.h | 115 -------------- PowerEditor/visual.net/notepadPlus.Cpp.props | 2 +- PowerEditor/visual.net/notepadPlus.vcxproj | 2 - 8 files changed, 52 insertions(+), 373 deletions(-) delete mode 100644 PowerEditor/src/dpiManagerV2.cpp delete mode 100644 PowerEditor/src/dpiManagerV2.h diff --git a/PowerEditor/gcc/makefile b/PowerEditor/gcc/makefile index 8c8854e7b..1e3f2a34c 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_WIN10 NTDDI_VERSION=NTDDI_WIN10_RS5 TIXML_USE_STL TIXMLA_USE_STL +CPP_DEFINE := UNICODE _UNICODE OEMRESOURCE NOMINMAX _WIN32_WINNT=_WIN32_WINNT_VISTA 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 3297d4549..02365bd51 100644 --- a/PowerEditor/src/CMakeLists.txt +++ b/PowerEditor/src/CMakeLists.txt @@ -74,7 +74,6 @@ 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 @@ -204,7 +203,6 @@ SET(include_files ./DarkMode/IatHook.h ./DarkMode/UAHMenuBar.h ./dpiManager.h - ./dpiManagerV2.h ./keys.h ./localizationString.h ./MISC/Common/Sorters.h @@ -395,13 +393,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_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(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(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_WIN10 -DNTDDI_VERSION=NTDDI_WIN10_RS5 -D_USE_64BIT_TIME_T -DTIXML_USE_STL -DTIXMLA_USE_STL -DNOMINMAX -DOEMRESOURCE) + SET(defs -DUNICODE -D_UNICODE -D_WIN32_WINNT=_WIN32_WINNT_VISTA -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 56b8c085b..27b57c787 100644 --- a/PowerEditor/src/NppDarkMode.cpp +++ b/PowerEditor/src/NppDarkMode.cpp @@ -26,7 +26,6 @@ #include "Parameters.h" #include "resource.h" -#include "dpiManagerV2.h" #include @@ -49,7 +48,7 @@ //#pragma comment(lib, "uxtheme.lib") //#endif -static constexpr COLORREF HEXRGB(DWORD rrggbb) { +constexpr COLORREF HEXRGB(DWORD rrggbb) { // from 0xRRGGBB like natural #RRGGBB // to the little-endian 0xBBGGRR return @@ -1002,7 +1001,7 @@ namespace NppDarkMode } }; - static void renderButton(HWND hwnd, HDC hdc, HTHEME hTheme, int iPartID, int iStateID) + void renderButton(HWND hwnd, HDC hdc, HTHEME hTheme, int iPartID, int iStateID) { RECT rcClient{}; WCHAR szText[256] = { '\0' }; @@ -1086,7 +1085,7 @@ namespace NppDarkMode SelectObject(hdc, hOldFont); } - static void paintButton(HWND hwnd, HDC hdc, ButtonData& buttonData) + 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); @@ -1161,7 +1160,7 @@ namespace NppDarkMode constexpr UINT_PTR g_buttonSubclassID = 42; - static LRESULT CALLBACK ButtonSubclass( + LRESULT CALLBACK ButtonSubclass( HWND hWnd, UINT uMsg, WPARAM wParam, @@ -1186,28 +1185,18 @@ namespace NppDarkMode RemoveWindowSubclass(hWnd, ButtonSubclass, g_buttonSubclassID); delete pButtonData; break; - case WM_ERASEBKGND: - { if (NppDarkMode::isEnabled() && pButtonData->ensureTheme(hWnd)) { return TRUE; } - break; - } - - case WM_DPICHANGED: - { - pButtonData->closeTheme(); - return 0; - } - + else + { + break; + } case WM_THEMECHANGED: - { pButtonData->closeTheme(); break; - } - case WM_PRINTCLIENT: case WM_PAINT: if (NppDarkMode::isEnabled() && pButtonData->ensureTheme(hWnd)) @@ -1255,7 +1244,7 @@ namespace NppDarkMode SetWindowSubclass(hwnd, ButtonSubclass, g_buttonSubclassID, pButtonData); } - static void paintGroupbox(HWND hwnd, HDC hdc, ButtonData& buttonData) + void paintGroupbox(HWND hwnd, HDC hdc, ButtonData& buttonData) { auto nStyle = ::GetWindowLongPtr(hwnd, GWL_STYLE); bool isDisabled = (nStyle & WS_DISABLED) == WS_DISABLED; @@ -1348,7 +1337,7 @@ namespace NppDarkMode constexpr UINT_PTR g_groupboxSubclassID = 42; - static LRESULT CALLBACK GroupboxSubclass( + LRESULT CALLBACK GroupboxSubclass( HWND hWnd, UINT uMsg, WPARAM wParam, @@ -1367,28 +1356,18 @@ namespace NppDarkMode RemoveWindowSubclass(hWnd, GroupboxSubclass, g_groupboxSubclassID); delete pButtonData; break; - case WM_ERASEBKGND: - { if (NppDarkMode::isEnabled() && pButtonData->ensureTheme(hWnd)) { return TRUE; } - break; - } - - case WM_DPICHANGED: - { - pButtonData->closeTheme(); - return 0; - } - + else + { + break; + } case WM_THEMECHANGED: - { pButtonData->closeTheme(); break; - } - case WM_PRINTCLIENT: case WM_PAINT: if (NppDarkMode::isEnabled() && pButtonData->ensureTheme(hWnd)) @@ -1409,6 +1388,10 @@ namespace NppDarkMode return 0; } + else + { + break; + } break; } return DefSubclassProc(hWnd, uMsg, wParam, lParam); @@ -1422,7 +1405,7 @@ namespace NppDarkMode constexpr UINT_PTR g_tabSubclassID = 42; - static LRESULT CALLBACK TabSubclass( + LRESULT CALLBACK TabSubclass( HWND hWnd, UINT uMsg, WPARAM wParam, @@ -1509,15 +1492,15 @@ namespace NppDarkMode ::SendMessage(hWnd, TCM_GETITEM, i, reinterpret_cast(&tci)); - const auto dpi = DPIManagerV2::getDpiForParent(hWnd); + auto dpiManager = NppParameters::getInstance()._dpiManager; RECT rcText = rcItem; - rcText.left += DPIManagerV2::scale(5, dpi); - rcText.right -= DPIManagerV2::scale(3, dpi); + rcText.left += dpiManager.scaleX(5); + rcText.right -= dpiManager.scaleX(3); if (isSelectedTab) { - rcText.bottom -= DPIManagerV2::scale(4, dpi); + rcText.bottom -= dpiManager.scaleY(4); ::InflateRect(&rcFrame, 0, 1); } if (i != nTabs - 1) @@ -1582,44 +1565,9 @@ 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; - static LRESULT CALLBACK CustomBorderSubclass( + LRESULT CALLBACK CustomBorderSubclass( HWND hWnd, UINT uMsg, WPARAM wParam, @@ -1628,7 +1576,7 @@ namespace NppDarkMode DWORD_PTR dwRefData ) { - auto pBorderMetricsData = reinterpret_cast(dwRefData); + UNREFERENCED_PARAMETER(dwRefData); static bool isHotStatic = false; @@ -1646,21 +1594,21 @@ namespace NppDarkMode HDC hdc = ::GetWindowDC(hWnd); RECT rcClient{}; ::GetClientRect(hWnd, &rcClient); - rcClient.right += (2 * pBorderMetricsData->_xEdge); + rcClient.right += (2 * ::GetSystemMetrics(SM_CXEDGE)); auto style = ::GetWindowLongPtr(hWnd, GWL_STYLE); bool hasVerScrollbar = (style & WS_VSCROLL) == WS_VSCROLL; if (hasVerScrollbar) { - rcClient.right += pBorderMetricsData->_xScroll; + rcClient.right += ::GetSystemMetrics(SM_CXVSCROLL); } - rcClient.bottom += (2 * pBorderMetricsData->_yEdge); + rcClient.bottom += (2 * ::GetSystemMetrics(SM_CYEDGE)); bool hasHorScrollbar = (style & WS_HSCROLL) == WS_HSCROLL; if (hasHorScrollbar) { - rcClient.bottom += pBorderMetricsData->_yScroll; + rcClient.bottom += ::GetSystemMetrics(SM_CYHSCROLL); } HPEN hPen = ::CreatePen(PS_SOLID, 1, NppDarkMode::getBackgroundColor()); @@ -1696,32 +1644,25 @@ namespace NppDarkMode } auto lpRect = reinterpret_cast(lParam); - ::InflateRect(lpRect, -(pBorderMetricsData->_xEdge), -(pBorderMetricsData->_yEdge)); + ::InflateRect(lpRect, -(::GetSystemMetrics(SM_CXEDGE)), -(::GetSystemMetrics(SM_CYEDGE))); auto style = ::GetWindowLongPtr(hWnd, GWL_STYLE); bool hasVerScrollbar = (style & WS_VSCROLL) == WS_VSCROLL; if (hasVerScrollbar) { - lpRect->right -= pBorderMetricsData->_xScroll; + lpRect->right -= ::GetSystemMetrics(SM_CXVSCROLL); } bool hasHorScrollbar = (style & WS_HSCROLL) == WS_HSCROLL; if (hasHorScrollbar) { - lpRect->bottom -= pBorderMetricsData->_yScroll; + lpRect->bottom -= ::GetSystemMetrics(SM_CYHSCROLL); } 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()) @@ -1774,22 +1715,20 @@ namespace NppDarkMode case WM_NCDESTROY: { RemoveWindowSubclass(hWnd, CustomBorderSubclass, uIdSubclass); - delete pBorderMetricsData; } break; } return DefSubclassProc(hWnd, uMsg, wParam, lParam); } - static void subclassCustomBorderForListBoxAndEditControls(HWND hwnd) + void subclassCustomBorderForListBoxAndEditControls(HWND hwnd) { - auto pBorderMetricsData = reinterpret_cast(new BorderMetricsData(hwnd)); - SetWindowSubclass(hwnd, CustomBorderSubclass, g_customBorderSubclassID, pBorderMetricsData); + SetWindowSubclass(hwnd, CustomBorderSubclass, g_customBorderSubclassID, 0); } constexpr UINT_PTR g_comboBoxSubclassID = 42; - static LRESULT CALLBACK ComboBoxSubclass( + LRESULT CALLBACK ComboBoxSubclass( HWND hWnd, UINT uMsg, WPARAM wParam, @@ -1820,7 +1759,7 @@ namespace NppDarkMode auto holdBrush = ::SelectObject(hdc, NppDarkMode::getDarkerBackgroundBrush()); - const auto dpi = DPIManagerV2::getDpiForParent(hWnd); + auto& dpiManager = NppParameters::getInstance()._dpiManager; RECT rcArrow{}; @@ -1835,7 +1774,7 @@ namespace NppDarkMode else { rcArrow = { - rc.right - DPIManagerV2::scale(17, dpi), rc.top + 1, + rc.right - dpiManager.scaleX(17), rc.top + 1, rc.right - 1, rc.bottom - 1 }; } @@ -1918,7 +1857,7 @@ namespace NppDarkMode }; ::Polyline(hdc, edge, _countof(edge)); - const int roundCornerValue = NppDarkMode::isWindows11() ? DPIManagerV2::scale(4, dpi) : 0; + int roundCornerValue = NppDarkMode::isWindows11() ? dpiManager.scaleX(4) : 0; NppDarkMode::paintRoundFrameRect(hdc, rc, hSelectedPen, roundCornerValue, roundCornerValue); ::SelectObject(hdc, holdPen); @@ -2015,7 +1954,7 @@ namespace NppDarkMode constexpr UINT_PTR g_upDownSubclassID = 42; - static LRESULT CALLBACK UpDownSubclass( + LRESULT CALLBACK UpDownSubclass( HWND hWnd, UINT uMsg, WPARAM wParam, @@ -2121,12 +2060,6 @@ namespace NppDarkMode return FALSE; } - case WM_DPICHANGED: - { - pButtonData->closeTheme(); - return 0; - } - case WM_THEMECHANGED: { pButtonData->closeTheme(); @@ -2155,7 +2088,7 @@ namespace NppDarkMode return DefSubclassProc(hWnd, uMsg, wParam, lParam); } - static void subclassAndThemeUpDownControl(HWND hwnd, NppDarkModeParams p) + void subclassAndThemeUpDownControl(HWND hwnd, NppDarkModeParams p) { if (p._subclass) { @@ -2482,12 +2415,8 @@ namespace NppDarkMode { if (NppDarkMode::isEnabled()) { - if (NppDarkMode::isWindows11()) - { - const auto nmhdr = reinterpret_cast(lParam); - const auto dpi = DPIManagerV2::getDpiForParent(nmhdr->hwndFrom); - roundCornerValue = DPIManagerV2::scale(5, dpi); - } + auto dpiManager = NppParameters::getInstance()._dpiManager; + roundCornerValue = NppDarkMode::isWindows11() ? dpiManager.scaleX(5) : 0; ::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 97fd51443..da6fae4f6 100644 --- a/PowerEditor/src/dpiAware.manifest +++ b/PowerEditor/src/dpiAware.manifest @@ -1,14 +1,9 @@ - - - true - - - system, unaware - - - false - - + + + true + + \ No newline at end of file diff --git a/PowerEditor/src/dpiManagerV2.cpp b/PowerEditor/src/dpiManagerV2.cpp deleted file mode 100644 index 86d25be5a..000000000 --- a/PowerEditor/src/dpiManagerV2.cpp +++ /dev/null @@ -1,126 +0,0 @@ -// 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 deleted file mode 100644 index c24968272..000000000 --- a/PowerEditor/src/dpiManagerV2.h +++ /dev/null @@ -1,115 +0,0 @@ -// 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 f3fbd9e8b..26609f63a 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_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) + 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) Async Level4 true diff --git a/PowerEditor/visual.net/notepadPlus.vcxproj b/PowerEditor/visual.net/notepadPlus.vcxproj index d149a2510..97517da0b 100755 --- a/PowerEditor/visual.net/notepadPlus.vcxproj +++ b/PowerEditor/visual.net/notepadPlus.vcxproj @@ -114,7 +114,6 @@ - @@ -243,7 +242,6 @@ -