From 8ac13d90654e5ebaff2167582c7b24751d38b6ce Mon Sep 17 00:00:00 2001 From: ozone10 Date: Sat, 14 Aug 2021 14:48:45 +0200 Subject: [PATCH] Make dark mode compatible with Windows 11 Use documented way to enable UxTheme dialog texture. Remove undocumented way. Disable UxTheme dialog texture in dark mode. Fix #10299, close #10383 --- PowerEditor/src/NppDarkMode.cpp | 5 +- .../src/ScintillaComponent/FindReplaceDlg.cpp | 7 +-- .../src/ScintillaComponent/columnEditor.cpp | 9 --- .../src/WinControls/AboutDlg/AboutDlg.cpp | 10 --- .../WinControls/ColourPicker/WordStyleDlg.cpp | 9 --- .../WinControls/PluginsAdmin/pluginsAdmin.cpp | 5 -- .../WinControls/Preference/preferenceDlg.cpp | 63 +------------------ 7 files changed, 5 insertions(+), 103 deletions(-) diff --git a/PowerEditor/src/NppDarkMode.cpp b/PowerEditor/src/NppDarkMode.cpp index 87776b07c..a8474fd6d 100644 --- a/PowerEditor/src/NppDarkMode.cpp +++ b/PowerEditor/src/NppDarkMode.cpp @@ -1433,10 +1433,7 @@ namespace NppDarkMode , theme }; - if (subclass) - { - ::EnableThemeDialogTexture(hwndParent, theme ? ETDT_ENABLETAB : ETDT_DISABLE); - } + ::EnableThemeDialogTexture(hwndParent, theme && !NppDarkMode::isEnabled() ? ETDT_ENABLETAB : ETDT_DISABLE); EnumChildWindows(hwndParent, [](HWND hwnd, LPARAM lParam) { auto& p = *reinterpret_cast(lParam); diff --git a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp index f1657a381..0b6656e79 100644 --- a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp @@ -14,8 +14,8 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . + #include -#include #include "FindReplaceDlg.h" #include "ScintillaEditView.h" #include "Notepad_plus_msgs.h" @@ -300,10 +300,6 @@ void FindReplaceDlg::create(int dialogID, bool isRTL, bool msgDestParent) _initialWindowRect.bottom = _initialWindowRect.bottom - _initialWindowRect.top; _initialWindowRect.top = 0; - ETDTProc enableDlgTheme = (ETDTProc)::SendMessage(_hParent, NPPM_GETENABLETHEMETEXTUREFUNC, 0, 0); - if (enableDlgTheme) - enableDlgTheme(_hSelf, ETDT_ENABLETAB); - NppParameters& nppParam = NppParameters::getInstance(); NppGUI& nppGUI = nppParam.getNppGUI(); if (nppGUI._findWindowPos.bottom - nppGUI._findWindowPos.top != 0) // check height against 0 as a test of valid data from config @@ -713,7 +709,6 @@ INT_PTR CALLBACK FindInFinderDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker(); pNativeSpeaker->changeDlgLang(_hSelf, "FindInFinder"); - EnableThemeDialogTexture(_hSelf, ETDT_ENABLETAB); NppDarkMode::autoSubclassAndThemeChildControls(_hSelf); initFromOptions(); diff --git a/PowerEditor/src/ScintillaComponent/columnEditor.cpp b/PowerEditor/src/ScintillaComponent/columnEditor.cpp index e9e19bede..170045849 100644 --- a/PowerEditor/src/ScintillaComponent/columnEditor.cpp +++ b/PowerEditor/src/ScintillaComponent/columnEditor.cpp @@ -17,8 +17,6 @@ #include #include -#include -#include #include "columnEditor.h" #include "ScintillaEditView.h" @@ -50,13 +48,6 @@ INT_PTR CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA ::SendDlgItemMessage(_hSelf, IDC_COL_DEC_RADIO, BM_SETCHECK, TRUE, 0); goToCenter(); - NppParameters& nppParam = NppParameters::getInstance(); - ETDTProc enableDlgTheme = (ETDTProc)nppParam.getEnableThemeDlgTexture(); - if (enableDlgTheme) - { - enableDlgTheme(_hSelf, ETDT_ENABLETAB); - redraw(); - } return TRUE; } diff --git a/PowerEditor/src/WinControls/AboutDlg/AboutDlg.cpp b/PowerEditor/src/WinControls/AboutDlg/AboutDlg.cpp index c5aa4d439..f0b8a8e46 100644 --- a/PowerEditor/src/WinControls/AboutDlg/AboutDlg.cpp +++ b/PowerEditor/src/WinControls/AboutDlg/AboutDlg.cpp @@ -15,9 +15,6 @@ // along with this program. If not, see . -#include -#include - #include "AboutDlg.h" #include "Parameters.h" #include "localization.h" @@ -61,13 +58,6 @@ INT_PTR CALLBACK AboutDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPara getClientRect(_rc); - ETDTProc enableDlgTheme = (ETDTProc)nppParam.getEnableThemeDlgTexture(); - if (enableDlgTheme) - { - enableDlgTheme(_hSelf, ETDT_ENABLETAB); - redraw(); - } - return TRUE; } diff --git a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp index 53326b529..392da9250 100644 --- a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp +++ b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp @@ -15,9 +15,7 @@ // along with this program. If not, see . -#include #include -#include #include "WordStyleDlg.h" #include "ScintillaEditView.h" @@ -147,13 +145,6 @@ INT_PTR CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l ::EnableWindow(::GetDlgItem(_hSelf, IDOK), _isDirty); ::EnableWindow(::GetDlgItem(_hSelf, IDC_SAVECLOSE_BUTTON), FALSE/*!_isSync*/); - ETDTProc enableDlgTheme = (ETDTProc)nppParamInst.getEnableThemeDlgTexture(); - if (enableDlgTheme) - { - enableDlgTheme(_hSelf, ETDT_ENABLETAB); - redraw(); - } - updateGlobalOverrideCtrls(); setVisualFromStyleList(); goToCenter(); diff --git a/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp b/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp index f89da4c4a..3fc98caeb 100644 --- a/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp +++ b/PowerEditor/src/WinControls/PluginsAdmin/pluginsAdmin.cpp @@ -22,7 +22,6 @@ #include #include #include -#include #include "pluginsAdmin.h" #include "ScintillaEditView.h" #include "localization.h" @@ -394,10 +393,6 @@ void PluginsAdminDlg::create(int dialogID, bool isRTL, bool msgDestParent) switchDialog(0); - ETDTProc enableDlgTheme = (ETDTProc)::SendMessage(_hParent, NPPM_GETENABLETHEMETEXTUREFUNC, 0, 0); - if (enableDlgTheme) - enableDlgTheme(_hSelf, ETDT_ENABLETAB); - goToCenter(); } diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index 62b8a01b8..c628886b8 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -15,8 +15,6 @@ // along with this program. If not, see . #include -#include -#include #include "preferenceDlg.h" #include "lesDlgs.h" #include "EncodingMapper.h" @@ -206,11 +204,6 @@ INT_PTR CALLBACK PreferenceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM _cloudAndLinkSubDlg.reSizeTo(rc); _searchEngineSubDlg.reSizeTo(rc); - NppParameters& nppParam = NppParameters::getInstance(); - ETDTProc enableDlgTheme = (ETDTProc)nppParam.getEnableThemeDlgTexture(); - if (enableDlgTheme) - enableDlgTheme(_hSelf, ETDT_ENABLETAB); - NppDarkMode::autoSubclassAndThemeChildControls(_hSelf); return TRUE; @@ -502,10 +495,6 @@ INT_PTR CALLBACK GeneralSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) if (index != CB_ERR) ::SendDlgItemMessage(_hSelf, IDC_COMBO_LOCALIZATION, CB_SETCURSEL, index, 0); - ETDTProc enableDlgTheme = reinterpret_cast(nppParam.getEnableThemeDlgTexture()); - if (enableDlgTheme) - enableDlgTheme(_hSelf, ETDT_ENABLETAB); - return TRUE; } @@ -769,10 +758,7 @@ INT_PTR CALLBACK EditingSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM initScintParam(); - - ETDTProc enableDlgTheme = (ETDTProc)nppParam.getEnableThemeDlgTexture(); - if (enableDlgTheme) - enableDlgTheme(_hSelf, ETDT_ENABLETAB); + return TRUE; } @@ -1041,10 +1027,7 @@ INT_PTR CALLBACK DarkModeSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM ::EnableWindow(::GetDlgItem(_hSelf, IDC_RADIO_DARKMODE_CUSTOMIZED), nppGUI._darkmode._isEnabled); enableCustomizedColorCtrls(nppGUI._darkmode._isEnabled && id == IDC_RADIO_DARKMODE_CUSTOMIZED); - - ETDTProc enableDlgTheme = (ETDTProc)nppParam.getEnableThemeDlgTexture(); - if (enableDlgTheme) - enableDlgTheme(_hSelf, ETDT_ENABLETAB); + return TRUE; } @@ -1424,10 +1407,7 @@ INT_PTR CALLBACK MarginsBorderEdgeSubDlg::run_dlgProc(UINT message, WPARAM wPara ::SetDlgItemInt(_hSelf, IDC_DISTRACTIONFREEVAL_STATIC, svp._distractionFreeDivPart, FALSE); initScintParam(); - - ETDTProc enableDlgTheme = (ETDTProc)nppParam.getEnableThemeDlgTexture(); - if (enableDlgTheme) - enableDlgTheme(_hSelf, ETDT_ENABLETAB); + return TRUE; } @@ -1643,10 +1623,6 @@ INT_PTR CALLBACK MiscSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) ::SendDlgItemMessage(_hSelf, IDC_CHECK_STYLEMRU, BM_SETCHECK, nppGUI._styleMRU, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_SHORTTITLE, BM_SETCHECK, nppGUI._shortTitlebar, 0); - ETDTProc enableDlgTheme = (ETDTProc)nppParam.getEnableThemeDlgTexture(); - if (enableDlgTheme) - enableDlgTheme(_hSelf, ETDT_ENABLETAB); - return TRUE; } @@ -1966,12 +1942,6 @@ INT_PTR CALLBACK NewDocumentSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPA } ::SendDlgItemMessage(_hSelf, IDC_COMBO_DEFAULTLANG, CB_SETCURSEL, index, 0); - // - // To avoid the white control background to be displayed in dialog - // - ETDTProc enableDlgTheme = (ETDTProc)nppParam.getEnableThemeDlgTexture(); - if (enableDlgTheme) - enableDlgTheme(_hSelf, ETDT_ENABLETAB); } case WM_CTLCOLORLISTBOX: @@ -2125,13 +2095,6 @@ INT_PTR CALLBACK DefaultDirectorySubDlg::run_dlgProc(UINT message, WPARAM wParam ::EnableWindow(::GetDlgItem(_hSelf, IDC_OPENSAVEDIR_ALWAYSON_EDIT), shouldActivated); ::EnableWindow(::GetDlgItem(_hSelf, IDD_OPENSAVEDIR_ALWAYSON_BROWSE_BUTTON), shouldActivated); - // - // To avoid the white control background to be displayed in dialog - // - ETDTProc enableDlgTheme = (ETDTProc)nppParam.getEnableThemeDlgTexture(); - if (enableDlgTheme) - enableDlgTheme(_hSelf, ETDT_ENABLETAB); - ::SendDlgItemMessage(_hSelf, IDC_OPENSAVEDIR_CHECK_DRROPFOLDEROPENFILES, BM_SETCHECK, nppGUI._isFolderDroppedOpenFiles ? BST_CHECKED : BST_UNCHECKED, 0); } @@ -2258,13 +2221,6 @@ INT_PTR CALLBACK RecentFilesHistorySubDlg::run_dlgProc(UINT message, WPARAM wPar ::SetDlgItemInt(_hSelf, IDC_CUSTOMIZELENGTHVAL_STATIC, length, FALSE); _customLenVal.init(_hInst, _hSelf); _customLenVal.create(::GetDlgItem(_hSelf, IDC_CUSTOMIZELENGTHVAL_STATIC), nullptr); - - // - // To avoid the white control background to be displayed in dialog - // - ETDTProc enableDlgTheme = (ETDTProc)nppParam.getEnableThemeDlgTexture(); - if (enableDlgTheme) - enableDlgTheme(_hSelf, ETDT_ENABLETAB); } case WM_CTLCOLORDLG: @@ -2434,10 +2390,6 @@ INT_PTR CALLBACK LanguageSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM ::EnableWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC), FALSE); ::ShowWindow(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_DISABLE_STATIC), SW_HIDE); - ETDTProc enableDlgTheme = reinterpret_cast(nppParam.getEnableThemeDlgTexture()); - if (enableDlgTheme) - enableDlgTheme(_hSelf, ETDT_ENABLETAB); - ::SendDlgItemMessage(_hSelf, IDC_CHECK_BACKSLASHISESCAPECHARACTERFORSQL, BM_SETCHECK, nppGUI._backSlashIsEscapeCharacterForSql, 0); return TRUE; @@ -2844,10 +2796,6 @@ INT_PTR CALLBACK HighlightingSubDlg::run_dlgProc(UINT message, WPARAM wParam, LP ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_SMARTHILITEUSEFINDSETTINGS), nppGUI._enableSmartHilite); ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_SMARTHILITEANOTHERRVIEW), nppGUI._enableSmartHilite); - ETDTProc enableDlgTheme = reinterpret_cast(nppParam.getEnableThemeDlgTexture()); - if (enableDlgTheme) - enableDlgTheme(_hSelf, ETDT_ENABLETAB); - return TRUE; } @@ -3084,11 +3032,6 @@ INT_PTR CALLBACK PrintSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) } ::SendDlgItemMessage(_hSelf, IDC_COMBO_VARLIST, CB_SETCURSEL, 0, 0); - - - ETDTProc enableDlgTheme = (ETDTProc)nppParam.getEnableThemeDlgTexture(); - if (enableDlgTheme) - enableDlgTheme(_hSelf, ETDT_ENABLETAB); break; }