This website is using cookies. We use cookies to ensure that we give you the best experience on our website. More info. That's Fine
HPC:Factor Logo 
Latest Forum Activity

eVB ImageList replacement with mask (transparency) support

WinCEDev Page Icon Posted 2023-02-17 1:52 AM
Avatar image of WinCEDev
Factorite (Junior)

Hi again,

This project is sort of the final piece of the puzzle concerning my earlier Taskbar Icon and Notification Icon examples. This is a module and accompanying test project to directly work with Windows image lists. This module can fully replace the eVB ImageList control.

The most notable improvement is support for masked images, so it's possible to use icons with transparent backgrounds on the taskbar and notification area, as well as any of the native or third-party eVB controls that take a handle to an image list. It has always been odd to me how Microsoft did not add this ability to the native ImageList control as it's very trivial.

However even if you don't need transparency you can potentially save around 50kb and any COM registration headaches when distributing your app by not having to include the MSCEImageList.dll control. This is especially useful if you only intend to use it for a taskbar or notification area icon as you won't be needing any other references except for pvbdecl.dll.

A complete application could look like this:

'A CommandBar control has been added to the form. 
Private CommandBarIcons As Long 'This holds the image list handle.

Private Sub Form_Load()

'If you need support for transparency, set flags to 'ILC_COLOR Or ILC_MASK', otherwise, you can set it to just 'ILC_COLOR'.
CommandBarIcons = ImageListEx_Create(16, 16, ILC_COLOR Or ILC_MASK) 'Create the image list.

'Add the toolbar bitmap to the image list, we use magenta as our transparent color.
ImageListEx_AddMasked CommandBarIcons, "toolbar.bmp", vbMagenta

'Assign our image list handle to the CommandBar.
CommandBar.ImageList = CommandBarIcons

'At this point our image list is loaded and we can add a button as per normal.
Dim objButton As CommandBarButton

Set objButton = CommandBar.Controls.Add(cbrButton)
objButton.Image = 0 'Assign our image.

End Sub

Private Sub Form_Unload(Cancel As Integer)
'Make sure to always destroy the image list when the form containing it closes or the application ends.
ImageListEx_Destroy CommandBarIcons
End Sub

I have attached some screenshots of the example project showing the icons with various Windows themes applied.


GitHub Repo

P.S. If the admins/moderators feel like I'm creating too many threads please feel free to merge this and the other two example projects into a single thread/topic. I'm not really sure what's preferred and what would be easier to find later so if there are any recommendations in that regard please let me know!



Attachments CAPT0000.png (2KB - 0 downloads)
Attachments CAPT0001.png (2KB - 0 downloads)
 Top of the page
torch Page Icon Posted 2023-02-17 6:46 AM
Avatar image of torch
H/PC Vanguard

United States 
Looking fantastic ! Keep up the good work
 Top of the page
Jump to forum:
Seconds to generate: 0.125 - Cached queries : 42 - Executed queries : 27