MFC单文档如何更改工具栏图标???急!!!!

我用MFC创建了一个单文档、根据需要要更改工具栏按钮图标、我想导入自己现有的图标、这个怎么实现???不管用什么方法、在原工具栏的基础上也行、另创建一个工具栏也行!只要能解... 我用MFC创建了一个单文档、根据需要要更改工具栏按钮图标、
我想导入自己现有的图标、这个怎么实现???
不管用什么方法、在原工具栏的基础上也行、另创建一个工具栏也行!
只要能解决这个问题、最好回答详细点、刚学MFC不久、。。多谢了!
回答的好有加分!!!!!!!多谢各位!!!
展开
 我来答
砍侃看
2011-04-05 · TA获得超过6150个赞
知道大有可为答主
回答量:6584
采纳率:69%
帮助的人:1891万
展开全部
Visual C++ provides you with two methods to create a toolbar. To create a toolbar resource using the Resource Editor, follow these steps: //在资源编辑器中创建一个toolbar资源
Create a toolbar resource.//常见一个toolbar资源
Construct the CToolBar object.//构造一个toolbar对象
Call the Create (or CreateEx) function to create the Windows toolbar and attach it to the CToolBar object.//调用creat或者createx函数创建窗口toolbar并且将其与toolbar对象关联
Call LoadToolBar to load the toolbar resource.//调用 LoadToolBar载入toolbar资源

Otherwise, follow these steps:

Construct the CToolBar object.//构造CToolBar对象
Call the Create (or CreateEx) function to create the Windows toolbar and attach it to the CToolBar object.//调用Create (or CreateEx)函数创建窗口toolbar并关联到CToolBar 对象
Call LoadBitmap to load the bitmap that contains the toolbar button images.//调用LoadBitmap 载入包含了toolbar按钮图片的bitmap*****************载入图标操作,图标可以通过资源管理器导入。
Call SetButtons to set the button style and associate each button with an image in the bitmap.//调用SetButtons 设置按钮类型并且将每一个按钮和图片关联

All the button images in the toolbar are taken from one bitmap, which must contain one image for each button. All images must be the same size; the default is 16 pixels wide and 15 pixels high. Images must be side by side in the bitmap.//所有的工具栏按钮图片都来自于一个位图,且每一个按钮必须包含一个位图。所有的图片必须有相同的大小,默认时16像素宽,15像素高。图片必须边挨边在为图中。

上面是MSDN中的说明,很清楚的说明了如何向工具栏中添加图标。
1、在资源管理器中添加一个工具栏资源
2、定义一个工具栏对象并且和工具栏资源关联
3、用loadbitmap函数将图标载入到工具栏,LoadBitmap 函数的使用可以查阅MSDN
4、用SetButtons 将按钮和图片关联起来就行了
dukang9904455
2011-04-05 · TA获得超过811个赞
知道小有建树答主
回答量:1028
采纳率:0%
帮助的人:904万
展开全部
在原工具栏的基础上:
工具栏的对象(CToolBar m_wndToolBar)在frame里面。
首先获取
CToolBarCtrl tc= m_wndToolBar.GetToolBarCtrl( )

tc.AddBitmap(...)
/*
int AddBitmap( int nNumButtons, UINT nBitmapID );

int AddBitmap( int nNumButtons, CBitmap* pBitmap );
*/

tc.AddButtons(...)
/*
BOOL AddButtons( int nNumButtons, LPTBBUTTON lpButtons );
*/
具体看msdn
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
wangbwell
2011-04-05 · TA获得超过1238个赞
知道小有建树答主
回答量:490
采纳率:0%
帮助的人:710万
展开全部
需要自己绘制同样规格的bmp工具条,然后导入该工具条,修改ID即可
更多追问追答
追问
别骗我行吗,你这个回答是别人问过相同问题后,有人给的答案、一模一样。改都不改就拷过来、好意思啊
追答
根据需要要更改工具栏按钮图标??
随时更换?
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
08jcw1n27
2011-04-05 · TA获得超过410个赞
知道答主
回答量:539
采纳率:0%
帮助的人:291万
展开全部
具条,修改ID即可
追问
具条?
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
收起 更多回答(2)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式