Reputation:
I am having issues with creating my own Toolbar inside the Mainframe. I have bitmaps of buttons which I want to use for my own Toolbar but the problem is that the Toolbar displays inside the View of my SDI application. Here is a pic of the incorrectly displayed Toolbar.
http://www.flickr.com/photos/14402427@N02/3409050475/
Here is the code inside the OnCreate function of the Mainframe class : I also have a
// CToolBarCtrl m_wndToolBar; declared inside the MainFrame.h class.
if(m_wndToolBar.Create(WS_CHILD | TBSTYLE_FLAT | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC
,CRect(0,0,250,50),this,0))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
TBBUTTON tbbutton[3] = {0};
CSize button_size(90,90);
CSize bitmap_size(80,80);
//m_wndToolBar.AddStrings("String 1\0String 2\0String 3\0");
tbbutton[0].iBitmap = 0;
tbbutton[0].idCommand = ID_CONNECT;
tbbutton[0].fsState = TBSTATE_ENABLED;
tbbutton[0].fsStyle = TBSTYLE_BUTTON;
tbbutton[0].dwData = 0;
tbbutton[0].iString = 0;
tbbutton[1].iBitmap = 1;
tbbutton[1].idCommand = ID_DISCONNECT;
tbbutton[1].fsState = TBSTATE_ENABLED;
tbbutton[1].fsStyle = TBSTYLE_BUTTON;
tbbutton[1].dwData = 0;
tbbutton[1].iString = 1;
tbbutton[2].iBitmap = 2;
tbbutton[2].idCommand = ID_STOP;
tbbutton[2].fsState = TBSTATE_ENABLED;
tbbutton[2].fsStyle = TBSTYLE_BUTTON ;
tbbutton[2].dwData = 0;
tbbutton[2].iString = 2;
m_wndToolBar.SetButtonSize(button_size);
m_wndToolBar.SetBitmapSize( bitmap_size);
m_wndToolBar.AddButtons(3,tbbutton);
m_wndToolBar.AddBitmap(1,IDB_BITMAP1);
m_wndToolBar.AddBitmap(1,IDB_BITMAP2);
m_wndToolBar.AddBitmap(1,IDB_BITMAP3);
return TRUE;
Upvotes: 0
Views: 953
Reputation: 68691
Add a call to DockControlBar(&m_wndToolBar)
just before the return
.
Upvotes: 1
Reputation: 3013
From your image it seems that it is not painted or not painted correctly, did you try adding bitmaps first and then adding buttons? or can you call AutoSize on the m_wndToolbarBar.?
Upvotes: 0