将 PNG 用于 CToolBar 对象时出现问题

Issue when using PNGs into CToolBar object

我正在尝试将 CImageList 插入到名为 m_wndUtilBarCToolBar 对象中。我使用以下代码添加所有图像:

CImageList imageList;
CBitmap bitmap;
COLORREF crMask = RGB(192, 192, 192);

CSize button, button_img;
button.cx = 39; 
button.cy = 39; 
button_img.cx = 32; 
button_img.cy = 32;
m_wndUtilBar.SetSizes(button, button_img);

imageList.Create(button_img.cx, button_img.cy, ILC_COLOR32 | ILC_MASK, 18, 1);

LoadBitmapFromPNG(IDB_PNG_UP, bitmap);
imageList.Add(&bitmap, crMask);
bitmap.Detach();
.
.
. // adding more images into the list
.

然后我将列表添加到对象中,如下所示:

m_wndUtilBar.GetToolBarCtrl().SetImageList(&imageList);
imageList.Detach();

我使用的所有图像都是项目中包含的资源,不是位图而是 PNG(我这么说是因为我认为这就是问题所在)。

一旦我 运行 应用程序一切正常。显示所有图像并且按钮工作正常。但是,当我禁用其中一个按钮时,此按钮的图像显示为已启用(没有那种典型的灰色禁用遮罩),我不知道为什么。

有人可以帮助我吗?我不知道如何将禁用效果应用于禁用按钮的图像。

更新 1

我看到禁用效果只出现在图像的边框上,所以我认为应用了该效果,但是在 PNG 内部没有应用该效果。

您可能还需要为禁用状态提供 png 图形。

来自文档:

Using Image Lists in a Toolbar Control

你需要使用 SetDisabledImageList() 和 SetHotImageList() 来处理类似的东西。