我一直在尝试将CMFCMenuBar和CMFCToolBar放在一起。 CFrameWndEx的OnCreate具有以下代码
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);
显示的结果UI类似于
我的问题有两个问题。 1.为什么工具栏上没有显示任何图标? 2.为什么菜单栏不会横向占据整个可用空间?