MFC Toolbar icon not visible in Visual Studio 2015

这一生的挚爱 提交于 2019-12-25 08:25:33

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!