Forum
Please
Log In
to post a new message or reply to an existing one. If you are not registered, please
register.
NOTE: Some forums may be read-only if you are not currently subscribed to
our technical support services.
Subject |
Author |
Date |
|
Ian McIntosh
|
May 1, 2007 - 5:55 AM
|
If I right click on the title bar of a CExtControlBar it brings up a menu with a list of bars that can be shown.
However, I have a bar that is initially auto hidden. If I right click on that bar’s tab while the bar is hidden I get an assertion failure in CExtPopupMenuWnd::ItemInsert() when it gets a NULL back from g_CmdManager->CmdGetPtr().
I stepped into g_CmdManager->CmdGetPtr() and it seems that my auto hidden bar is not listed in the CmdManager.
NOTE: The assert only happens if I haven’t already displayed the list by right clicking on a title bar first - once i have done that right clicking on a hidden bar’s tab works correctly.
I wonder if there is a problem in my OnCreate() method. This is it:
int CMainFrame::OnCreate( LPCREATESTRUCT lpCreateStruct ) { if( CExtNCW < CMDIFrameWnd > :: OnCreate( lpCreateStruct ) == -1 ) return -1; ///////////////////////////////////////////////////////// // STEP 1: Initialize the command manager ///////////////////////////////////////////////////////// CWinApp * pApp = ::AfxGetApp(); ASSERT( pApp != NULL ); ASSERT( pApp->m_pszRegistryKey != NULL ); ASSERT( pApp->m_pszRegistryKey[0] != _T(’\0’) ); ASSERT( pApp->m_pszProfileName != NULL ); ASSERT( pApp->m_pszProfileName[0] != _T(’\0’) ); VERIFY( g_CmdManager->ProfileWndAdd( __PROF_UIS_PROJECT_CMD_PROFILE_NAME, GetSafeHwnd() ) ); VERIFY( g_CmdManager->UpdateFromMenu( __PROF_UIS_PROJECT_CMD_PROFILE_NAME, IDR_MAINFRAME ) ); VERIFY( g_CmdManager->UpdateFromMenu( __PROF_UIS_PROJECT_CMD_PROFILE_NAME, IDR_GuiMdiTYPE ) ); ///////////////////////////////////////////////////////// // STEP 2: Pre-initialize fixed size bars // (menu bar, ribbon bar, toolbars) ///////////////////////////////////////////////////////// if( ! m_wndRibbonBar.Create( NULL, this ) ) { TRACE0("Failed to create the m_wndRibbonBar toolbar\n"); ASSERT( FALSE ); return -1; // fail to create } m_wndRibbonBar.Init();
///////////////////////////////////////////////////////// // STEP 3: Pre-initialize resizable bars ///////////////////////////////////////////////////////// HFONT hDefaultGuiFont = (HFONT) ::GetStockObject( DEFAULT_GUI_FONT ); if( hDefaultGuiFont == NULL ) { hDefaultGuiFont = (HFONT) ::GetStockObject( SYSTEM_FONT ); ASSERT( hDefaultGuiFont != NULL ); } // Init System tree (part 1): m_wndSystemTree.SetInitDesiredSizeVertical( CSize( 200, 400 ) ); m_wndSystemTree.SetInitDesiredSizeHorizontal( CSize( 400, 200 ) ); if( ! m_wndSystemTree.Create( _T("System Tree"), this, ID_SYSTEM_TREE ) ) { TRACE0("Failed to create m_wndSystemTree\n"); ASSERT( FALSE ); return -1; // fail to create } if( ! m_wndSystemTreeCtrl.Create( CTreeMainDlg::IDD, &m_wndSystemTree ) ) { TRACE0("Failed to create m_wndSystemTreeCtrl\n"); ASSERT( FALSE ); return -1; // fail to create } m_wndSystemTree.SetFont( CFont::FromHandle( hDefaultGuiFont ) ); // Init Resource tree (part 1): m_wndResourceTree.SetInitDesiredSizeVertical( CSize( 200, 400 ) ); m_wndResourceTree.SetInitDesiredSizeHorizontal( CSize( 400, 200 ) ); if( ! m_wndResourceTree.Create( _T("Resource Tree"), this, ID_RESOURCE_TREE ) ) { TRACE0("Failed to create m_wndResourceTree\n"); ASSERT( FALSE ); return -1; // fail to create } if( ! m_wndResourceTreeCtrl.Create( WS_CHILD|WS_VISIBLE|WS_VSCROLL|WS_HSCROLL |TVS_HASBUTTONS|TVS_HASLINES|TVS_LINESATROOT |TVS_INFOTIP|TVS_DISABLEDRAGDROP |TVS_SHOWSELALWAYS, CRect( 0, 0, 0, 0 ), &m_wndResourceTree, m_wndResourceTree.GetDlgCtrlID() ) ) { TRACE0("Failed to create m_wndResourceTreeCtrl\n"); ASSERT( FALSE ); return -1; // fail to create } m_wndResourceTree.SetFont( CFont::FromHandle( hDefaultGuiFont ) ); // Init Selection List (part 1): m_wndSelectionList.SetInitDesiredSizeVertical( CSize( 100, 200 ) ); if( ! m_wndSelectionList.Create( _T("Selection List"), this, ID_SELECTION_LIST ) ) { TRACE0("Failed to create m_wndSelectionList\n"); ASSERT( FALSE ); return -1; // fail to create } if( ! m_wndSelectionListCtrl.Create( CSelectionDlg::IDD, &m_wndSelectionList ) ) { TRACE0("Failed to create m_wndSelectionListCtrl\n"); ASSERT( FALSE ); return -1; // fail to create } m_wndSelectionList.SetFont( CFont::FromHandle( hDefaultGuiFont ) ); // Init Indicators (part 1): m_wndIndicators.SetInitDesiredSizeVertical( CSize( 100, 200 ) ); if( ! m_wndIndicators.Create( _T("Indicators"), this, IDD_DLG_INDICATOR_GRID ) ) { TRACE0("Failed to create m_wndIndicators\n"); ASSERT( FALSE ); return -1; // fail to create } if( ! m_wndIndicatorsCtrl.Create( IDD_DLG_INDICATOR_GRID, &m_wndIndicators ) ) { int i = GetLastError(); TRACE0("Failed to create m_wndIndicatorsCtrl\n"); ASSERT( FALSE ); return -1; // fail to create } m_wndIndicators.SetFont( CFont::FromHandle( hDefaultGuiFont ) );
// Init State Dialog (part 1): m_wndState.SetInitDesiredSizeVertical( CSize( 200, 400 ) ); //m_wndState.SetInitDesiredSizeHorizontal( CSize( 400, 200 ) ); if( ! m_wndState.Create( _T("State"), this, IDD_STATE_DIALOG ) ) { TRACE0("Failed to create State Dialog\n"); ASSERT( FALSE ); return -1; // fail to create } if( ! m_wndStateCtrl.Create( IDD_STATE_DIALOG, &m_wndState ) ) { TRACE0("Failed to create State Dlg Ctrl\n"); ASSERT( FALSE ); return -1; // fail to create } m_wndState.SetFont( CFont::FromHandle( hDefaultGuiFont ) ); ///////////////////////////////////////////////////////// // STEP 4: Initialize status bar ///////////////////////////////////////////////////////// if( (! m_wndStatusBar.Create( this ) ) || (! m_wndStatusBar.SetIndicators( indicators, sizeof(indicators)/sizeof(UINT) ) ) ) { TRACE0("Failed to create status bar\n"); ASSERT( FALSE ); return -1; // fail to create } ///////////////////////////////////////////////////////// // STEP 5: Enable re-docking feature only for those // bars which need it ///////////////////////////////////////////////////////// // Init System tree (part 2): m_wndSystemTree.EnableDocking( CBRS_ALIGN_ANY ); // Init Resource tree (part 2): m_wndResourceTree.EnableDocking( CBRS_ALIGN_ANY ); // Init Selection List (part 2): m_wndSelectionList.EnableDocking( CBRS_ALIGN_ANY ); // Init Indicators (part 2): m_wndIndicators.EnableDocking( CBRS_ALIGN_ANY ); // Init State Dialog (part 2): m_wndState.EnableDocking( CBRS_ALIGN_ANY ); ///////////////////////////////////////////////////////// // STEP 6: Enable re-docking feature only for entire // main frame window and, optionally, enable // enable auto-hiding feature fore resizable // bars ///////////////////////////////////////////////////////// // Enable control bars in the frame window to be redocable if( ! CExtControlBar::FrameEnableDocking( this ) ) { ASSERT( FALSE ); return -1; } // Enable autohide feature for resizable control bars if( ! CExtControlBar::FrameInjectAutoHideAreas( this ) ) { ASSERT( FALSE ); return -1; } ///////////////////////////////////////////////////////// // STEP 7: Load command manager state if needed ///////////////////////////////////////////////////////// // g_CmdManager->SerializeState( // __PROF_UIS_PROJECT_CMD_PROFILE_NAME, // pApp->m_pszRegistryKey, // pApp->m_pszProfileName, // false // ); ///////////////////////////////////////////////////////// // STEP 8: Try to load state of all the bars and dock // all of them initially if the state loading // was failed ///////////////////////////////////////////////////////// /* if( ! CExtControlBar::ProfileBarStateLoad( this, pApp->m_pszRegistryKey, pApp->m_pszProfileName, pApp->m_pszProfileName, &m_dataFrameWP ) ) */ { // Init System tree (part 3): m_wndSystemTree.DockControlBarInnerOuter( AFX_IDW_DOCKBAR_LEFT, true ); // Init Resource tree (part 3): m_wndResourceTree.DockControlBarInnerOuter( AFX_IDW_DOCKBAR_LEFT, true ); m_wndResourceTree.AutoHideModeSet(true, true, true, false); // Init Selection List (part 3): m_wndSelectionList.DockControlBarLTRB( &m_wndSystemTree, AFX_IDW_DOCKBAR_BOTTOM ); m_wndIndicators.DockControlBarInnerOuter( AFX_IDW_DOCKBAR_BOTTOM, true ); m_wndIndicators.AutoHideModeSet(true, true, true, false);
m_wndState.DockControlBarInnerOuter( AFX_IDW_DOCKBAR_BOTTOM, true ); m_wndState.AutoHideModeSet(true, true, true, false); } ///////////////////////////////////////////////////////// // STEP 9: Initialize other features. Embeddable controls // such as MDI tabs should be initialized here ///////////////////////////////////////////////////////// if( ! m_wndMdiManager.Create( this, CRect( 0, 0, 0, 0 ), UINT( IDC_STATIC ), WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS, __ETWS_ORIENT_TOP|__ETWS_ENABLED_BTN_CLOSE|__ETWS_SHOW_BTN_CLOSE ) ) { ASSERT( FALSE ); return -1; } RecalcLayout(); return 0; }
|
|
Technical Support
|
May 1, 2007 - 11:03 AM
|
Please try the following:
- create a new menu resource for commands that display/hide control bars - add a command for each control bar - update the command manager with this menu resource
The problem should be gone. Please note the menu will never be used as a pop-up menu in your project.
|
|