我想创建一个带有自定义图像按钮的工具栏,我有 .ico 格式的图像,如何将它们添加到 WTL 中的工具栏?我正在尝试编辑工具栏列表中的图像,但质量很差,如何添加质量更好的图像?
最佳答案
如果您已经创建了 WTL 工具栏控件,则可以使用 SetImageList()
将图像附加到它。和SetHotImageList()
CToolBarCtrl
的方法类(class)。例如
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 ...
然后可以通过引用 CImageList:Add()
的返回值来使用图像。方法。
确保将图像列表与 CImageList
分离。类,就像我在这里所做的那样,否则当图像列表超出范围时将被删除。
关于c++ - 自定义图像工具栏 WTL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12602734/