Implement dark mode using win32-darkmodelib - #1203
Conversation
|
Please wait a bit, looks I don't understand why it's need to subcalss all common controls. |
Isn't the code 8k lines? Those common controls won't render correctly in dark mode. Some part of the control will still rendering the way in light theme. E.g. buttons render as light, or some background render as light. I didn't find a simple way to fix them without subclass them. In fact notepad++ also does the same way (subclass those controls). |
It matters at least for matepath: |
matepath is a different project right? Haven't looked into support darkmode on it yet. |
|
This is a long overdue feature, it would be nice to be able to implement it. 💪🏻 |
Address PR zufuliu#1203 feedback: scroll bars and the save-changes dialog were rendered in the light theme even when dark mode is active. - Enable scroll bar fix in darkmodelib (mode 2: per-window) and rely on the existing enableDarkScrollBarForWindowAndChildren(hwndMain) call so the Scintilla edit window's scroll bars use the dark theme. - Route Notepad4's MsgBox() through dmlib::darkMessageBoxW(), which renders message boxes as themed task dialogs when dark mode is on. - Fix two upstream darkmodelib namespacing bugs that surface when _DARKMODELIB_USE_SCROLLBAR_FIX is defined (DmlibHook.cpp uses ModuleHandle / LoadFn without the dmlib_module:: prefix). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Address PR zufuliu#1203 feedback: scroll bars and the save-changes dialog were rendered in the light theme even when dark mode is active. - Enable scroll bar fix in darkmodelib (mode 2: per-window) and rely on the existing enableDarkScrollBarForWindowAndChildren(hwndMain) call so the Scintilla edit window's scroll bars use the dark theme. - Route Notepad4's MsgBox() through dmlib::darkMessageBoxW(), which renders message boxes as themed task dialogs when dark mode is on. - Fix two upstream darkmodelib namespacing bugs that surface when _DARKMODELIB_USE_SCROLLBAR_FIX is defined (DmlibHook.cpp uses ModuleHandle / LoadFn without the dmlib_module:: prefix). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Address PR zufuliu#1203 feedback: scroll bars and the save-changes dialog were rendered in the light theme even when dark mode is active. - Enable scroll bar fix in darkmodelib (mode 2: per-window) and rely on the existing enableDarkScrollBarForWindowAndChildren(hwndMain) call so the Scintilla edit window's scroll bars use the dark theme. - Route Notepad4's MsgBox() through dmlib::darkMessageBoxW(), which renders message boxes as themed task dialogs when dark mode is on. - Fix two upstream darkmodelib namespacing bugs that surface when _DARKMODELIB_USE_SCROLLBAR_FIX is defined (DmlibHook.cpp uses ModuleHandle / LoadFn without the dmlib_module:: prefix). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Great job, @lostindark it looks really nice now. Well done!
|
Address PR zufuliu#1203 feedback: scroll bars and the save-changes dialog were rendered in the light theme even when dark mode is active. - Enable scroll bar fix in darkmodelib (mode 2: per-window) and rely on the existing enableDarkScrollBarForWindowAndChildren(hwndMain) call so the Scintilla edit window's scroll bars use the dark theme. - Route Notepad4's MsgBox() through dmlib::darkMessageBoxW(), which renders message boxes as themed task dialogs when dark mode is on. - Fix two upstream darkmodelib namespacing bugs that surface when _DARKMODELIB_USE_SCROLLBAR_FIX is defined (DmlibHook.cpp uses ModuleHandle / LoadFn without the dmlib_module:: prefix). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Address PR zufuliu#1203 feedback: scroll bars and the save-changes dialog were rendered in the light theme even when dark mode is active. - Enable scroll bar fix in darkmodelib (mode 2: per-window) and rely on the existing enableDarkScrollBarForWindowAndChildren(hwndMain) call so the Scintilla edit window's scroll bars use the dark theme. - Route Notepad4's MsgBox() through dmlib::darkMessageBoxW(), which renders message boxes as themed task dialogs when dark mode is on. - Fix two upstream darkmodelib namespacing bugs that surface when _DARKMODELIB_USE_SCROLLBAR_FIX is defined (DmlibHook.cpp uses ModuleHandle / LoadFn without the dmlib_module:: prefix). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Address PR zufuliu#1203 feedback: scroll bars and the save-changes dialog were rendered in the light theme even when dark mode is active. - Enable scroll bar fix in darkmodelib (mode 2: per-window) and rely on the existing enableDarkScrollBarForWindowAndChildren(hwndMain) call so the Scintilla edit window's scroll bars use the dark theme. - Route Notepad4's MsgBox() through dmlib::darkMessageBoxW(), which renders message boxes as themed task dialogs when dark mode is on. - Fix two upstream darkmodelib namespacing bugs that surface when _DARKMODELIB_USE_SCROLLBAR_FIX is defined (DmlibHook.cpp uses ModuleHandle / LoadFn without the dmlib_module:: prefix). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Address PR zufuliu#1203 feedback so that scroll bars, message boxes, the file open/save dialog, and toolbar button rollovers all render correctly when dark mode is toggled on or off. - Enable per-window scroll bar fix in darkmodelib (mode 2) so the Scintilla edit window's scroll bars use the dark theme via the existing enableDarkScrollBarForWindowAndChildren(hwndMain) call. - Route Notepad4's MsgBox() through dmlib::darkMessageBoxW(), which renders message boxes as themed task dialogs when dark mode is on. - Broadcast WM_THEMECHANGED to hwndMain and all descendants after a theme switch so themed controls (including scroll bars) re-open their theme handles and pick up the new light/dark style. - Gate the OpenNcThemeData IAT hook on IsDarkModeActive() so scroll bars revert to the light theme after switching back from dark. - Gate the WM_INITDIALOG thread hook on isExperimentalActive() and on the dialog's HINSTANCE matching this app's module, so system dialogs hosted in our process (common file open/save, etc.) are left untouched. - Subclass the main window with setWindowNotifyCustomDrawSubclass so darkmodelib can custom-draw toolbar buttons (dark hover/checked states) via the toolbar's NM_CUSTOMDRAW notifications, which the rebar forwards up to its parent. This matches Notepad++'s approach. - Fix two upstream darkmodelib namespacing bugs that surface when _DARKMODELIB_USE_SCROLLBAR_FIX is defined (DmlibHook.cpp uses ModuleHandle / LoadFn without the dmlib_module:: prefix). - Add missing #include <string_view> in DmlibHook.cpp so MinGW GCC/Clang builds compile (upstream pulls this in via StdAfx.h which we do not vendor). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Fixed in latest commit. |
…ntrol to make text rendered same as system MessageBox, PR #1203.
|
Using |
44837e8 to
a328d8b
Compare
|
|
|
Customize toolbar dialog can be changed to handle case IDC_TOOLBAR:
switch (pnmh->code) {
case TBN_BEGINADJUST:
DialogHook_Start(DialogRefData_CustomizeToolbar);
break;
case TBN_ENDADJUST:
DialogHook_Stop();
UpdateToolbar();
break; |
Vendor the win32-darkmodelib library (https://github.com/ozone10/win32-darkmodelib) under darkmodelib/, mirroring upstream's src/ + include/ layout. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Integrate darkmodelib into Notepad4: dark mode application logic (DarkMode.cpp/.h and calls from Notepad4.cpp, Styles.cpp, Dialogs.cpp), build wiring for the darkmodelib library, and the local patches to the vendored library (disableDarkScrollBarForWindowAndChildren and the light/dark toolbar theming color fixes). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
darkmodelib's DmlibDpi.cpp dynamically loads per-monitor DPI v2 functions (GetDpiForWindow, GetSystemMetricsForDpi, AdjustWindowRectExForDpi, GetDpiForSystem) that Notepad4 already loads via Scintilla_LoadDpiForWindow(). This duplicated the loader and the associated dummy fallbacks. Add a _DARKMODELIB_EXTERNAL_DPI opt-in macro: when defined, DmlibDpi.cpp's implementation is compiled out and the host supplies the dmlib_dpi functions the library actually uses. Notepad4 defines the macro (next to _DARKMODELIB_NO_INI_CONFIG) and implements the seven referenced functions in DarkMode.cpp, backed by its existing GetWindowDPI()/SystemMetricsForDpi()/ AdjustWindowRectForDpi()/g_uSystemDPI helpers. Only the two functions Notepad4 does not already load (SystemParametersInfoForDpi, OpenThemeDataForDpi) are resolved here, with fallbacks for pre-Windows 10. Standalone darkmodelib builds leave the macro undefined and are unchanged. Verified building both the Win10 (x64) macro path and the Vista (x86) function path. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Refine dark-mode handling for readonly edit controls, dialog size grips, InfoBox footer painting, Customize Toolbar, and large style trees. Remove the dark-mode edit focus underline for stability. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep the original status bar style and draw the grip only when the parent window is not maximized, as requested in PR review feedback. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 56a074ad-2620-4723-bc7a-d4c4d27d3d6b
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f46aad52-5daa-4cad-b776-cba02af08ed1
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f46aad52-5daa-4cad-b776-cba02af08ed1
|
Dialog hook code may be changed to use |
Brings in zufuliu's dialog hook fix for PR zufuliu#1203 (7dd7e6d: WH_CALLWNDPROCRET -> WH_CBT + HCBT_CREATEWND) and aa47287. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 389d2c14-09b4-4bab-b751-ab8429f573eb
Upstream ozone10/win32-darkmodelib fa996472 (2026-07-26). Local patches were replayed via a three-way merge and all preserved; the only conflict was upstream changing `const LRESULT retValText` to `const auto` next to our `_DARKMODELIB_CUSTOM_MEM` resize guard in paintStatusBar(). `dmlib_hook::hookSysColor()`/`unhookSysColor()` were reorganized upstream into the `dmlib_hook::GetSysColor` hook group, so DarkMode.cpp now calls `GetSysColor::hook()`/`GetSysColor::unhook()`. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9ffbe22e-365b-41a6-a0ec-e69b19c8823c
darkmodelib v0.75.0 added dark mode support for the common font and color dialogs. It draws the parts those dialogs render themselves: the font preview, the owner-drawn font combo boxes, the ChooseColor luminosity slider, and the message boxes ChooseFont raises. All of that lives in the library's internal ComDlgSubclass, which is installed by dmlib::HookDlgProc. darkmodelib documents driving that hook via CF_ENABLEHOOK | CF_ENABLETEMPLATE with a custom IDD_DARK_FONT_DIALOG template, because a hook alone makes Windows fall back to a legacy font dialog template. That is a poor fit here: the template would have to be duplicated into Notepad4.rc and all eleven locale/*/Notepad4.rc files, and the font dialog would permanently lose the automatic system translation of its captions and static texts. Notepad4 already hooks dialog creation with WH_CBT + HCBT_CREATEWND, which does not trigger the template downgrade. So route the common dialogs through the existing DialogHook with a new DialogRefData_CommonDialog and call dmlib::HookDlgProc() from DarkMode_ApplyDialogStyling(). The system's modern, localized template is kept and no new resources are needed. DialogRefData_CommonDialog sorts after DialogRefData_DefaultPosition, so the dialogs keep placing themselves as before. Also refresh the common dialog brushes on theme change; the luminosity slider brush is derived from the darker text color, which DarkMode_SetCustomColors() overrides. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9ffbe22e-365b-41a6-a0ec-e69b19c8823c












Vendor ozone10/win32-darkmodelib source files directly in darkmodelib/ to provide native Windows dark mode support for Notepad4's UI chrome, tied to the existing Style Theme (Default/Dark) setting.
Features: