Reputation: 3637
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?
Upvotes: 2
Views: 1230
Reputation: 4713
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.
Upvotes: 2