diff --git a/PowerEditor/src/DarkMode/DarkMode.cpp b/PowerEditor/src/DarkMode/DarkMode.cpp index dea942634..08e04d225 100644 --- a/PowerEditor/src/DarkMode/DarkMode.cpp +++ b/PowerEditor/src/DarkMode/DarkMode.cpp @@ -258,6 +258,11 @@ constexpr bool CheckBuildNumber(DWORD buildNumber) buildNumber >= 22000); // Windows 11 insider builds } +bool IsWindows11() // or later OS version +{ + return (g_buildNumber >= 22000); +} + void InitDarkMode() { fnRtlGetNtVersionNumbers RtlGetNtVersionNumbers = nullptr; diff --git a/PowerEditor/src/DarkMode/DarkMode.h b/PowerEditor/src/DarkMode/DarkMode.h index 3a79111b9..7de3ba11e 100644 --- a/PowerEditor/src/DarkMode/DarkMode.h +++ b/PowerEditor/src/DarkMode/DarkMode.h @@ -15,3 +15,4 @@ void AllowDarkModeForApp(bool allow); void EnableDarkScrollBarForWindowAndChildren(HWND hwnd); void InitDarkMode(); void SetDarkMode(bool useDarkMode, bool fixDarkScrollbar); +bool IsWindows11(); diff --git a/PowerEditor/src/NppDarkMode.cpp b/PowerEditor/src/NppDarkMode.cpp index a3756df84..724083995 100644 --- a/PowerEditor/src/NppDarkMode.cpp +++ b/PowerEditor/src/NppDarkMode.cpp @@ -364,6 +364,11 @@ namespace NppDarkMode return g_darkModeSupported; } + bool isWindows11() + { + return IsWindows11(); + } + COLORREF invertLightness(COLORREF c) { WORD h = 0; @@ -1146,34 +1151,6 @@ namespace NppDarkMode SetWindowSubclass(hwnd, GroupboxSubclass, g_groupboxSubclassID, pButtonData); } - constexpr UINT_PTR g_toolbarSubclassID = 42; - - LRESULT CALLBACK ToolbarSubclass( - HWND hWnd, - UINT uMsg, - WPARAM wParam, - LPARAM lParam, - UINT_PTR uIdSubclass, - DWORD_PTR dwRefData - ) - { - UNREFERENCED_PARAMETER(uIdSubclass); - UNREFERENCED_PARAMETER(dwRefData); - - switch (uMsg) - { - case WM_NCDESTROY: - RemoveWindowSubclass(hWnd, ToolbarSubclass, g_toolbarSubclassID); - break; - } - return DefSubclassProc(hWnd, uMsg, wParam, lParam); - } - - void subclassToolbarControl(HWND hwnd) - { - SetWindowSubclass(hwnd, ToolbarSubclass, g_toolbarSubclassID, 0); - } - constexpr UINT_PTR g_tabSubclassID = 42; LRESULT CALLBACK TabSubclass( diff --git a/PowerEditor/src/NppDarkMode.h b/PowerEditor/src/NppDarkMode.h index a639390d1..2cb60fc77 100644 --- a/PowerEditor/src/NppDarkMode.h +++ b/PowerEditor/src/NppDarkMode.h @@ -83,6 +83,8 @@ namespace NppDarkMode bool isDarkMenuEnabled(); bool isExperimentalSupported(); + bool isWindows11(); + COLORREF invertLightness(COLORREF c); COLORREF invertLightnessSofter(COLORREF c); double calculatePerceivedLighness(COLORREF c); @@ -145,7 +147,6 @@ namespace NppDarkMode void subclassButtonControl(HWND hwnd); void subclassGroupboxControl(HWND hwnd); - void subclassToolbarControl(HWND hwnd); void subclassTabControl(HWND hwnd); void subclassComboBoxControl(HWND hwnd); diff --git a/PowerEditor/src/WinControls/ToolBar/ToolBar.cpp b/PowerEditor/src/WinControls/ToolBar/ToolBar.cpp index e00b76bcb..0cec13cd6 100644 --- a/PowerEditor/src/WinControls/ToolBar/ToolBar.cpp +++ b/PowerEditor/src/WinControls/ToolBar/ToolBar.cpp @@ -306,6 +306,11 @@ void ToolBar::reset(bool create) { setDefaultImageListDM(); setDisableImageListDM(); + + if (NppDarkMode::isWindows11()) + { + setHoveredImageListDM(); + } } else { @@ -319,6 +324,11 @@ void ToolBar::reset(bool create) { setDefaultImageListDM2(); setDisableImageListDM2(); + + if (NppDarkMode::isWindows11()) + { + setHoveredImageListDM2(); + } } else { @@ -534,8 +544,7 @@ void ReBar::init(HINSTANCE hInst, HWND hPere) _hSelf = CreateWindowEx(WS_EX_TOOLWINDOW, REBARCLASSNAME, NULL, - WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|RBS_VARHEIGHT| - CCS_NODIVIDER | CCS_NOPARENTALIGN, + WS_CHILD|WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | RBS_VARHEIGHT | CCS_NODIVIDER | CCS_NOPARENTALIGN, 0,0,0,0, _hParent, NULL, _hInst, NULL); SetWindowSubclass(_hSelf, RebarSubclass, g_rebarSubclassID, 0); diff --git a/PowerEditor/src/WinControls/ToolBar/ToolBar.h b/PowerEditor/src/WinControls/ToolBar/ToolBar.h index 649feab06..2fbc3c89d 100644 --- a/PowerEditor/src/WinControls/ToolBar/ToolBar.h +++ b/PowerEditor/src/WinControls/ToolBar/ToolBar.h @@ -146,6 +146,14 @@ private : void setDisableImageListDM2() { ::SendMessage(_hSelf, TB_SETDISABLEDIMAGELIST, 0, reinterpret_cast(_toolBarIcons.getDisableLstSetDM2())); }; + + void setHoveredImageListDM() { + ::SendMessage(_hSelf, TB_SETHOTIMAGELIST, 0, reinterpret_cast(_toolBarIcons.getDefaultLst())); + }; + + void setHoveredImageListDM2() { + ::SendMessage(_hSelf, TB_SETHOTIMAGELIST, 0, reinterpret_cast(_toolBarIcons.getDefaultLstSet2())); + }; void reset(bool create = false); void setState(toolBarStatusType state) {