Add new API NPPM_ADDTOOLBARICON_FORDARKMODE for dark mode
-
Usage:
void NPPM_ADDTOOLBARICON_FORDARKMODE(UINT funcItem[X]._cmdID, toolbarIconsWithDarkMode iconHandles)This new API
NPPM_ADDTOOLBARICON_FORDARKMODEis for replacing obsoleteNPPM_ADDTOOLBARICONwhich doesn’t support the dark mode.
2 formats / 3 icons are needed: 1 * BMP + 2 * ICOAll 3 handles below should be set so the icon will be displayed correctly if toolbar icon sets are changed by users, also in dark mode.
struct toolbarIconsWithDarkMode { HBITMAP hToolbarBmp; HICON hToolbarIcon; HICON hToolbarIconDarkMode; };You can find the demo here:
https://github.com/npp-plugins/plugindemo -
Hi @donho
Since the
NPPM_ADDTOOLBARICONmessage is being deprecated I do have a suggestion.Many existing plugins are still using this old message. This causes missing icons on the toolbar for plugins when Notepad++ is configured to use Fluent UI.
I would suggest slightly modifying the behavior of
NPPM_ADDTOOLBARICONso that it reuses thehToolbarIconicon in place of thehToolbarIconDarkModeicon.This would at least allow a plugin to have ugly icons when using Fluent UI rather than icons that are completely missing.
-
@dail said in Add new API NPPM_ADDTOOLBARICON_FORDARKMODE for dark mode:
Many existing plugins are still using this old message. This causes missing icons on the toolbar for plugins when Notepad++ is configured to use Fluent UI.
I would suggest slightly modifying the behavior of NPPM_ADDTOOLBARICON so that it reuses the hToolbarIcon icon in place of the hToolbarIconDarkMode icon.
This would at least allow a plugin to have ugly icons when using Fluent UI rather than icons that are completely missing.Message
NPPM_ADDTOOLBARICONworks as usual in the newest version of Notepad++ for all plugins which use this message. It doesn’t support only dark mode.The new API
NPPM_ADDTOOLBARICON_FORDARKMODEfor dark mode is here for substitutingNPPM_ADDTOOLBARICON, so the retro-compatibility is remained.OTOH, there’s no way to extend
NPPM_ADDTOOLBARICONsince the pointer of icons handles structure is passed as arguments. -
@donho said in Add new API NPPM_ADDTOOLBARICON_FORDARKMODE for dark mode:
OTOH, there’s no way to extend NPPM_ADDTOOLBARICON since the pointer of icons handles structure is passed as arguments.
I’m not suggesting modifying the struct, just to use the one icon in the struct in all cases to prevent missing icons.
-
@dail said in Add new API NPPM_ADDTOOLBARICON_FORDARKMODE for dark mode:
I’m not suggesting modifying the struct, just to use the one icon in the struct in all cases to prevent missing icons.
I will see what I can do about it.
-
@dail said in Add new API NPPM_ADDTOOLBARICON_FORDARKMODE for dark mode:
Your suggestion has been implemented and merged in master:
https://github.com/notepad-plus-plus/notepad-plus-plus/commit/302bab894fd421fde371e04247357bc45728d729 -
@donho said in Add new API NPPM_ADDTOOLBARICON_FORDARKMODE for dark mode:
Your suggestion has been implemented and merged in master:
Using Fluent icons in non-dark mode with some non-fluent plugin icons and Customize Toolbar plugin - ALL WORKS!!!

Great!
Thank you!
Cheers.
-
@donho
Was just starting to implement darkmode icons…
What happens with plugins used in older versions of NPP?
I guess I’m not the only one facing this for some time.
I would implement both messages and make the choice by the NPP version:if (8 <= HIWORD(execute(nppHandle, NPPM_GETNPPVERSION))) { // version 8 did introduce the dark mode g_TBIconsDrk.hToolbarBmp = (HBITMAP)::LoadImage(_findDlg.getHinst(), MAKEINTRESOURCE(IDB_TB_ANALYSE), IMAGE_BITMAP, 0, 0, (LR_DEFAULTSIZE | LR_LOADMAP3DCOLORS)); g_TBIconsDrk.hToolbarIcon = (HICON)::LoadIcon(_findDlg.getHinst(), MAKEINTRESOURCE(IDI_ANALYSE_NEW)); g_TBIconsDrk.hToolbarIconDarkMode = (HICON)::LoadIcon(_findDlg.getHinst(), MAKEINTRESOURCE(IDI_ANALYSE_NEW_DRK)); execute(nppHandle, NPPM_ADDTOOLBARICON_FORDARKMODE, (WPARAM)funcItem[SHOWFINDDLG]._cmdID, (LPARAM)&g_TBIconsDrk); } else { g_TBIconsOld.hToolbarBmp = (HBITMAP)::LoadImage(_findDlg.getHinst(), MAKEINTRESOURCE(IDB_TB_ANALYSE), IMAGE_BITMAP, 0, 0, (LR_DEFAULTSIZE | LR_LOADMAP3DCOLORS)); g_TBIconsOld.hToolbarIcon = (HICON)::LoadIcon(_findDlg.getHinst(), MAKEINTRESOURCE(IDI_ANALYSE)); execute(nppHandle, NPPM_ADDTOOLBARICON_DEPRECATED, (WPARAM)funcItem[SHOWFINDDLG]._cmdID, (LPARAM)&g_TBIconsOld); }This works with older versions also.
Comments?
rgds, Mattes -
D donho unpinned this topic on