如何使用CMFCToolBar从位图图像创建工具栏 [英] How to create toolbar from a bitmap image using CMFCToolBar

查看:132
本文介绍了如何使用CMFCToolBar从位图图像创建工具栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.
这是一个奇怪的问题.除了由应用程序向导"创建的默认标准工具栏外,我想创建其他工具栏.我得到了 userdefinedtb.bmp (使用工具栏绘画创建).这是代码:

*** MainFrm.h ***

Hello, everyone.
Here is a weird question. I would like to create an additional toolbar besides the default standard toolbar created by App Wizard. And I got a userdefinedtb.bmp (created using Toolbar Paint). Here is the code:

*** MainFrm.h ***

CMFCToolBar m_wndToolBar, m_wndFEToolBar;



*** MainFrm.cpp ***



*** MainFrm.cpp ***

if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !m_wndToolBar.LoadToolBar(theApp.m_bHiColorIcons ? IDR_MAINFRAME_256 : IDR_MAINFRAME))	
{
 TRACE0("Failed to create toolbar\n");
 return -1; // fail to create
}
if (!m_wndFEToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, CRect(1, 1, 1, 1), IDR_TOOLBAR1) || !m_wndFEToolBar.LoadToolBar(IDR_TOOLBAR1) || !m_wndFEToolBar.LoadBitmap(IDB_FE_TB_BITMAP)) 
{
 TRACE0("Failed to create toolbar\n");
 return -1; // fail to create
}
// The code about docking
m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);	
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
m_wndFEToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockPane(&m_wndMenuBar);
DockPane(&m_wndToolBar);
DockPane(&m_wndFEToolBar);



IDR_TOOLBAR1是用户定义的工具栏的ID,IDB_FE_TB_BITMAP userdefinedtb.bmp 的资源ID.并且默认工具栏可以正确显示,但是 userdefinedtb.bmp 中的任何图像都不会显示在用户定义的工具栏上.因此,任何建议表示赞赏.感谢和抱歉,我的英语不好.



IDR_TOOLBAR1 is the ID of the user defined toolbar, IDB_FE_TB_BITMAP is the resource ID of userdefinedtb.bmp. And the default toolbar shows correctly, but none images in userdefinedtb.bmp are shown on the user defined toolbar. So any suggestions are appreciated. Thanks and sorry for my poor English.

推荐答案

以下是一些其他信息:
userdefinedtb.bmp ''的大小为32 * 16,每个图像的大小为16 * 16,因此 userdefinedtb.bmp 中有2张图像.在资源视图中,IDR_TOOLBAR1有2个按钮,其大小均为16 *16.按钮的内容是随便绘制的.
没有人熟悉CMFCToolBar吗?
Below are some additional information:
userdefinedtb.bmp''size is 32 * 16, each image''s size is 16 * 16, so there are 2 images in userdefinedtb.bmp. And in the Resource View, IDR_TOOLBAR1 has 2 buttons whose size are also 16 * 16. And the button''s content is drawn casually.
No one is familiar with CMFCToolBar?


if (!m_wndFEToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, CRect(1, 1, 1, 1), IDR_TOOLBAR1,IDB_FE_TB_BITMAP) || !m_wndFEToolBar.LoadToolBar(IDR_TOOLBAR1))
{
 TRACE0("Failed to create toolbar\n");
 return -1; // fail to create
}




使用代码,然后重试..




use the code ,try again..


这篇关于如何使用CMFCToolBar从位图图像创建工具栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆