CMFCToolbar:无法动态显示工具栏按钮上的图标 [英] CMFCToolbar : Unable to display icon on Toolbar button dynamically
问题描述
// hIcon是新图标图像的处理程序 if (hIcon) { CMFCToolBarImages * pImgList; pImgList = mytoolbar.GetImages(); int Index = mytoolbar.CommandToIndex(nID); CMFCToolBarButton * pButtonInfo = mytoolbar.GetButton(nIndex);
我们要加载图标并想在工具栏中显示该图标按钮。但是我们无法在动态添加的工具栏按钮上显示图标。这与旧的CToolbar类工作正常。请查看给定的示例代码。我们在工具栏上设置了PNG图像。可能无法用HBITMAP更新现有的png图像。
// UpdateImg在使用图标更新现有图像时失败了:pImgList-> UpdateImage(pButtonInfo-> GetImage(),(HBITMAP)hIcon);
mytoolbar.SetUserImages(pImgList);
< p class = MsoNormal style ="margin:0in 0in 12pt 0.25in"> mytoolbar.Invalidate(TRUE) ;
< span style ="font-size:small"> :: DestroyIcon(hIcon);
}
有谁有任何想法如何将自定义图像放在CMFCToolBar上? 我看到CMFCToolBarButton构造函数具有自定义图像的用户定义标志,但是没有示例如何操作。
Hi, //hIcon is handler of new icon image if(hIcon) { CMFCToolBarImages *pImgList; pImgList = mytoolbar.GetImages(); int Index = mytoolbar.CommandToIndex(nID); CMFCToolBarButton *pButtonInfo = mytoolbar.GetButton(nIndex); mytoolbar.Invalidate(TRUE); ::DestroyIcon( hIcon ); }
We want to load an icon and want to display that icon in a toolbar button. But we are unable display the icon on a dynamically added toolbar button. This was working fine with the old CToolbar class. Please have a look at the given sample code. We set PNG image on Toolbar. Might be it failed in updating existing png image with HBITMAP.
//UpdateImg is failed in updating existing image with icon
pImgList->UpdateImage(pButtonInfo->GetImage(),(HBITMAP)hIcon);
mytoolbar.SetUserImages(pImgList);
Is anyone has any idea how to put custom image on CMFCToolBar? I saw the CMFCToolBarButton constructor has user-defined flag for custom image, but there is no sample how to do it.
这篇关于CMFCToolbar:无法动态显示工具栏按钮上的图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!