2011-04-15 114 views
0

我已經使用嚮導在VS2008中構建了帶有功能包應用程序的選項卡式MDI MFC。 簡單地說,菜單欄不會恢復按鈕狀態。我也有一個工具欄來保存它的狀態。
我已檢查,並且CMFCMenuBar::SaveStateCMFCMenuBar::LoadState被調用,但只有菜單欄位置才能正確保存。任何人有任何想法可能是什麼原因呢?VS2008 MFC功能包 - 菜單(CMFCMenuBar)狀態不會保存

我還搜查了源代碼,我打電話完全相同的東西作爲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需要做什麼才能做到這一點?

我真的很需要解決這個問題。

回答

0
+1

對不起,但不是,情況並非如此。我正在使用標準工具欄和菜單欄,我沒有製作一個新菜單。重新加載應用程序後,菜單欄上放置的任何東西都不會再出現。菜單欄和工具欄位置正常,但之前移動的按鈕不再顯示。 – Pifcnt 2011-06-17 13:30:08