我已经在VS2008中使用向导构建了带有Feature Pack应用程序的选项卡式MDI MFC。
简单地说菜单栏不会恢复按钮状态。我还有一个工具栏,可以保存其状态
我已经检查过,CMFCMenuBar::SaveState
和CMFCMenuBar::LoadState
被调用,但只有菜单栏位置被正确保存。任何人有什么想法可能是什么原因?
我还搜索了源代码,我调用与VisualStudioDemo完全相同的东西(确实保存了正确的按钮顺序)。在CAppMainFrame::OnCreate
我这样做:
if (CMDIFrameWndEx::OnCreate(lpCreateStruct) == -1)
return -1;
BOOL bNameValid;
// set the visual manager and style based on persisted value
OnApplicationLook(theApp.m_nAppLook);
CMDITabInfo mdiTabParams;
//FEATURE: SET the App user MDI tabs Look & Feeel
mdiTabParams.m_style = CMFCTabCtrl::STYLE_3D; // other styles available...
mdiTabParams.m_bActiveTabCloseButton = FALSE; // set to FALSE to place close button at right of tab area
mdiTabParams.m_bTabIcons = FALSE; // set to TRUE to enable document icons on MDI taba
mdiTabParams.m_bAutoColor = FALSE; // set to FALSE to disable auto-coloring of MDI tabs
mdiTabParams.m_bDocumentMenu = FALSE; // enable the document menu at the right edge of the tab area
EnableMDITabbedGroups(TRUE, mdiTabParams);
//EnableMDITabs (TRUE,FALSE,CMFCTabCtrl::LOCATION_TOP,FALSE,CMFCTabCtrl::STYLE_3D_ROUNDED);
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);
//FEATURE: prevent the menu bar from taking the focus on activation
CMFCPopupMenu::SetForceMenuFocus(FALSE);
if (!m_wndMainToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndMainToolBar.LoadToolBar(theApp.m_bHiColorIcons ? IDR_MAINFRAME_256 : IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
CString strToolBarName;
bNameValid = strToolBarName.LoadString(IDS_TOOLBAR_STANDARD);
ASSERT(bNameValid);
m_wndMainToolBar.SetWindowText(strToolBarName);
CString strCustomize;
bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE);
ASSERT(bNameValid);
m_wndMainToolBar.EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize);
//FEATURE: Allow user-defined toolbars operations:
InitUserToolbars(NULL, uiFirstUserToolBarId, uiLastUserToolBarId);
if (!m_wndStatusBar.Create(this))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
//FEATURE: status bar indicators
m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT));
m_wndStatusBar.SetPaneStyle (1,SBPS_STRETCH );
m_wndStatusBar.SetPaneStyle (m_wndStatusBar.CommandToIndex(ID_INDICATOR_PIXELS),SBPS_NORMAL);
m_wndStatusBar.SetPaneStyle (m_wndStatusBar.CommandToIndex(ID_INDICATOR_DPI),SBPS_NORMAL);
m_wndStatusBar.SetPaneStyle (m_wndStatusBar.CommandToIndex(ID_INDICATOR_ZOOM),SBPS_NORMAL);
m_wndStatusBar.SetPaneText (m_wndStatusBar.CommandToIndex(ID_INDICATOR_PIXELS),m_strIndicatorPixels);
m_wndStatusBar.SetPaneText (m_wndStatusBar.CommandToIndex(ID_INDICATOR_DPI),m_strIndicatorDPI);
m_wndStatusBar.SetPaneText (m_wndStatusBar.CommandToIndex(ID_INDICATOR_ZOOM),m_strIndicatorZoom);
m_ilStatusSaveAnimation.CreateTC(IDB_SAVE_ANIMATION,16,15,RGB(255,0,255));
SetIndicatorSave(FALSE);
m_ilStatusBatchProcessing.CreateTC (IDB_PROCESSING_ANIMATION,16,15,RGB(255,0,255));
SetIndicatorBatchProcessing (FALSE);
//FEATURE: Delete these five lines if you don't want the toolbar and menubar to be dockable
m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
m_wndMainToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockPane(&m_wndMenuBar);
DockPane(&m_wndMainToolBar);
//FEATURE: enable Visual Studio 2005 style docking window behavior
CDockingManager::SetDockingMode(DT_SMART);
//FEATURE: enable Visual Studio 2005 style docking window auto-hide behavior
EnableAutoHidePanes(CBRS_ALIGN_ANY);
// Create a caption bar:
if (!CreateCaptionBar())
{
TRACE0("Failed to create caption bar\n");
return -1; // fail to create
}
// Load menu item image (not placed on any standard toolbars):
CMFCToolBar::AddToolBarForImageCollection(IDR_MENU_IMAGES, theApp.m_bHiColorIcons ? IDB_MENU_IMAGES_24 : 0);
// create docking windows
if (!CreateDockingWindows())
{
TRACE0("Failed to create docking windows\n");
return -1;
}
/*
CDockablePane* pTabbedBar = NULL;
m_wndFileView.EnableDocking(CBRS_ALIGN_ANY);
DockPane(&m_wndFileView);
//m_wndBatchView.AttachToTabWnd(&m_wndFileView, DM_SHOW, TRUE, &pTabbedBar);
*/
//replaced with:
m_wndBatchView.EnableDocking(CBRS_ALIGN_ANY);
DockPane(&m_wndBatchView,AFX_IDW_DOCKBAR_LEFT);
//FEATURE: Enable enhanced windows management dialog
EnableWindowsDialog(ID_WINDOW_MANAGER, IDS_WINDOWS_MANAGER, TRUE);
//FEATURE: Enable toolbar and docking window menu replacement
EnablePaneMenu(TRUE, ID_VIEW_CUSTOMIZE, strCustomize, ID_VIEW_TOOLBAR);
//FEATURE: enable quick (Alt+drag) toolbar customization
CMFCToolBar::EnableQuickCustomization();
if (CMFCToolBar::GetUserImages() == NULL)
{
// load user-defined toolbar images
if (m_UserImages.Load(_T(".\\UserImages.bmp")))
{
m_UserImages.SetImageSize(CSize(16, 16), FALSE);
CMFCToolBar::SetUserImages(&m_UserImages);
}
}
// enable menu personalization (most-recently used commands)
// TODO: define your own basic commands, ensuring that each pulldown menu has at least one basic command.
CList<UINT, UINT> lstBasicCommands;
...
你能弄清楚MFC Voodoo必须做些什么才能让它发挥作用吗?
我真的,真的需要解决这个问题。