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. |
|
Appearance for default theme is not good and doesn't match system default (looks old classic theme): This change increase exe size by 93KB, I think we needs some custom/samll version of darkmodelib, at least bugprone-exception-escape warnings needs to be fixed (e.g. by not use C++ STL). |
Both issues fixed. Though the smaller version of darmodelib might be tricky. |
|
Rework the integration, so the change is a bit easier to read. |
I'm still prefer custom smaller version:
deferred this to next release, I need some time to fix Markdown lexer crashes. |
…ntrol to make text rendered same as system MessageBox, PR #1203.
|
Using |
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
|
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 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: