问题
We have MFC Application and it has Toolbar, Toolbar use bmp 32 colors resource file in Visual Studio 2010. This application runs fine in VS2010.
After converting this application in Visual Studio 2015, toolbar icon does not visible. Visual Studio 2015 shows Format properties 32bpp BGR
Is anything change in VS2015 bitmap editor or Am I missing some properties settings here ?
回答1:
We are able to resolve this problem after creating low resource version of toolbar that MFC will accept. We have Created low resource id that should be refer to toolbar resource that has the identical layout as your original toolbar with respect to the command ids but reference to low resolution bmp file that MFC will accept.
Change following code in MainFrame::OnCreate
if (!m_wndToolBar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_FLOATING, IDR_LOWRES_RES_ID) || !m_wndToolBar.LoadToolBar(IDR_LOWRES_RES_ID))
{
TRACE0("Failed to create add fields bar\n");
return -1; // fail to create
}
//Added
//Replace imagelist with 32 bit bmp
CToolBarCtrl& ctl = m_wndToolBar.GetToolBarCtrl();
CImageList *pList = ctl.GetImageList();
// Delete low res image list
pList->DeleteImageList();
pList->Create(34, 34, ILC_COLOR32, 32, 0);
ctl.SetImageList(pList);
ctl.AddBitmap(32, IDR_ADD_HIGH_RES_ID);
来源:https://stackoverflow.com/questions/41953499/mfc-toolbar-icon-not-visible-in-visual-studio-2015