【问题标题】:Custom image toolbar WTL自定义图像工具栏 WTL
【发布时间】:2012-09-18 03:19:11
【问题描述】:

我想创建一个带有自定义图像按钮的工具栏,我有 .ico 格式的图像,如何将它们添加到 WTL 中的工具栏中?我正在尝试编辑工具栏列表中的图像,但是质量很差,如何添加质量更好的图像?

【问题讨论】:

  • 这里似乎有两个问题,如何更改 WTL 工具栏中使用的图像以及如何编辑图像本身。你可能想澄清一下。第一个问题的答案在于了解 CImageList

标签: c++ visual-studio wtl


【解决方案1】:

如果您已经创建了 WTL 工具栏控件,您可以使用 CToolBarCtrl 类的 SetImageList()SetHotImageList() 方法将图像附加到它。例如

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 类中分离出来,否则图像列表将在超出范围时被删除。

【讨论】:

猜你喜欢
  • 2012-05-10
  • 1970-01-01
  • 2015-10-08
  • 1970-01-01
  • 2013-08-20
  • 2015-05-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多