I have been trying to put a CMFCMenuBar and CMFCToolBar together. The OnCreate of CFrameWndEx has following code for the purpose
if ( !m_wndMenuBar.Create(this) ) {
TRACE0("Failed to create menubar\n");
return -1; // fail to create
}
m_wndMenuBar.SetPaneStyle( m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC | CBRS_TOOLTIPS | CBRS_FLYBY );
CMFCPopupMenu::SetForceMenuFocus(FALSE);
CList<UINT, UINT> lstBasicCommands;
lstBasicCommands.AddTail (ID_FILE_NEW);
lstBasicCommands.AddTail (ID_FILE_OPEN);
lstBasicCommands.AddTail (ID_FILE_SAVE);
lstBasicCommands.AddTail (ID_APP_EXIT);
lstBasicCommands.AddTail (ID_APP_ABOUT);
CMFCToolBar::SetBasicCommands (lstBasicCommands);
CMFCToolBarInfo toolBarStruct;
SecureZeroMemory( &toolBarStruct, sizeof(CMFCToolBarInfo) );
toolBarStruct.m_uiMenuResID = IDR_TOOLBAR;
m_wndToolBar.SetMenuSizes( CSize(21,22), CSize(15,16) );
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC ) ||//, CRect(1,1,1,1), theApp.m_bHiColorIcons ? IDR_TOOLBAR_MAIN_256 : IDR_TOOLBAR_MAIN ) ||
!m_wndToolBar.LoadToolBarEx(IDR_TOOLBAR, toolBarStruct) ) {
TRACE0("Failed to create toolbar\n");
return -1;
}
m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockPane(&m_wndMenuBar, CBRS_ALIGN_TOP);
DockPane(&m_wndToolBar);
The resultant UI that shows is something like
My question is two fold. 1. Why isnt the toolbar showing any icons? 2. Why isnt the menubar taking up the whole avaiable space horizontally?