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
This commit is contained in:
ozone10 2021-08-14 14:48:45 +02:00 committed by Don Ho
parent 4831cb80bd
commit 8ac13d9065
7 changed files with 5 additions and 103 deletions

View File

@ -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<Params*>(lParam);

View File

@ -14,8 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <shlwapi.h>
#include <uxtheme.h>
#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();

View File

@ -17,8 +17,6 @@
#include <vector>
#include <algorithm>
#include <shlobj.h>
#include <uxtheme.h>
#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;
}

View File

@ -15,9 +15,6 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <shlobj.h>
#include <uxtheme.h>
#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;
}

View File

@ -15,9 +15,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <shlobj.h>
#include <shlwapi.h>
#include <uxtheme.h>
#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();

View File

@ -22,7 +22,6 @@
#include <cctype>
#include <shlobj.h>
#include <shlwapi.h>
#include <uxtheme.h>
#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();
}

View File

@ -15,8 +15,6 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <shlwapi.h>
#include <shlobj.h>
#include <uxtheme.h>
#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<ETDTProc>(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<ETDTProc>(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<ETDTProc>(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;
}