本文介绍了MFC 工具栏图标在 Visual Studio 2015 中不可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有 MFC 应用程序,它有工具栏,工具栏在 Visual Studio 2010 中使用 bmp 32 色资源文件.此应用程序在 VS2010 中运行良好.

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.

在 Visual Studio 2015 中转换此应用程序后,工具栏图标不可见.Visual Studio 2015 显示格式属性 32bpp BGR

After converting this application in Visual Studio 2015, toolbar icon does not visible. Visual Studio 2015 shows Format properties 32bpp BGR

VS2015 位图编辑器有什么变化吗?或者我在这里遗漏了一些属性设置吗?

Is anything change in VS2015 bitmap editor or Am I missing some properties settings here ?

推荐答案

我们可以在创建 MFC 接受的低资源版本工具栏后解决这个问题.我们已经创建了低资源 id,它应该是指工具栏资源,该资源在命令 id 方面与原始工具栏具有相同的布局,但会引用 MFC 将接受的低分辨率 bmp 文件.

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.

在 MainFrame::OnCreate 中更改以下代码

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);

这篇关于MFC 工具栏图标在 Visual Studio 2015 中不可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 03:53