Click here to Skip to main content
15,889,892 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 ***
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 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.
Posted
Updated 9-May-10 5:30am
v2

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?
 
Share this answer
 
C#
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..
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900