as part of an attempt to write a simple plugin for Notepad++ I want to add a new icon to the Notepad++ toolbar
For doing so I need to call sendMessage_ with the correct paramters are described here in this C snippet:
Code: Select all
g_TBWndMgr.hToolbarBmp = (HBITMAP)::LoadImage( (HINSTANCE)g_hInstance, MAKEINTRESOURCE(IDB_EX_MULTICLIPBOARD), IMAGE_BITMAP, 0, 0, (LR_LOADMAP3DCOLORS) );
::SendMessage( g_NppData._nppHandle, NPPM_ADDTOOLBARICON, (WPARAM)funcItem[0]._cmdID, (LPARAM)&g_TBWndMgr ); } Code: Select all
Structure toolbarIcons
hToolbarBmp.l ;Handle for a BMP
hToolbarIcon.l ;Handle for a Icon
EndStructure
Global MyToolbaricon.toolbarIcons
hIcon = CatchImage(1, ?myIcon) ;get a OS handle to the icon
MyToolbaricon\hToolbarBmp = hIcon ;pass OS handle to structure
MyToolbaricon\hToolbarIcon = 0
;send NPPM_ADDTOOLBARICON message and Icon handle to NPP
ret=SendMessage_(LocalNppData\nppHnd , #NPPM_ADDTOOLBARICON, FI.FuncItem(0)\cmdID, @MyToolbaricon) ; result = black square
DataSection
myIcon: IncludeBinary "icon.bmp" ;BMP 16x16, 256 colors, also tested with .ICO file
EndDataSection(But when I click on it then my plugin is started...so this part works....)
From the information found here I understand that the .BMP format that is used in NPP is uncommon:
http://stackoverflow.com/questions/1383 ... hange-them
I have tested different .BMP and .ICO formats (converted with Irfanview) for my Icon but nothing worked –I see a black square only...
I even have extracted some icons from the Notepad++.exe just to have a sample image – but even if I try to add an original Icon to the toolbar it only shows a black square in the toolbar.
So I am not sure if my problem is a wrong BMP format (colors, transparency..) – maybe the problem is the coding, for example the sendmessage call ...?
But on the other hand if I click on that black square then my plugin is started...so it seems that the code basically works...
I dont know...maybe somebody has an idea what I can do..or maybe somebody can send me a .bmp or .ico that definitely works with NPP ..?
Heinz

