Question

I want to create a toolbar with custom image buttons, I have the images in .ico format how can I add them to the toolar in WTL? I'm trying to edit the images in the toolbar list, but there such poor quality, how can I add better quality images?

Was it helpful?

Solution

If you have a WTL Toolbar control that is already created you can attach images to it with the SetImageList() and SetHotImageList() methods of the CToolBarCtrl class. E.g.

CToolBarCtrl toolbar;
CImage image;
CBitmap bitmap;

// ... load the image into the bitmap ...

images.Create(32, 32, ILC_COLOR32 | ILC_MASK, 0, 1);

// repeat this for each image you want to use in the toolabr
images.Add(bitmap, RGB(255, 255, 255));

toolbar.SetImageList(images.Detach());

//... do the same for the hot (hover) images ...

The images can then be used by referencing the return value of the CImageList:Add() method.

Make sure you detach the image list from the CImageList class as I have done here otherwise the image list will be deleted when it goes out of scope.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top