New toolbar icon not showing on toolbar

I want to add a new icon to the Notepad ++ toolbar.
I tried the following code

internal static void SetToolBarIcon()
{
    toolbarIcons tbIcons = new toolbarIcons();
    tbIcons.hToolbarBmp = tbBmp.GetHbitmap();
    IntPtr pTbIcons = Marshal.AllocHGlobal(Marshal.SizeOf(tbIcons));
    Marshal.StructureToPtr(tbIcons, pTbIcons, false);
    Win32.SendMessage(PluginBase.nppData._nppHandle, NppMsg.NPPM_ADDTOOLBARICON, PluginBase._funcItems.Items[idMyDlg]._cmdID, pTbIcons);
    Marshal.FreeHGlobal(pTbIcons);
}     

Now my problem is that instead of the icon, I see only a black square on the toolbar

+3
source share
1 answer

Remember to save the icon in Resources.resx

0
source

All Articles