Professional UI Solutions
Site Map   /  Register
 
 

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.

Forums » Prof-UIS Tech Support » Getting an assertion error in CExtControlBar::ProfileBarStateLoad Collapse All
Subject Author Date
Scott Moore Nov 27, 2006 - 7:46 AM

I’m trying to setup my application to remember window and toolbar positions. I found the help docs which mentioned the steps you should take to do this, but I get an error with one of my toolbars on this line:

    if(!CExtControlBar::ProfileBarStateLoad(
        this,
        pApp->m_pszRegistryKey,
        pApp->m_pszProfileName,
        pApp->m_pszProfileName,
        &m_dataFrameWP
        )
    )
    {
        DockControlBar( &m_wndMenuBar );
        DockControlBar( &m_wndContentViews, AFX_IDW_DOCKBAR_RIGHT );
        DockControlBar( &m_wndCollectionToolbar, AFX_IDW_DOCKBAR_RIGHT );
    }


The call stack is this:

>    ProfUIS261ud.dll!CExtControlBar::InternalDockStateBar::StateSet(CFrameWnd * pDockSite=0x025f1fd8, CExtControlBar::InternalDockStateBar * pParentState=0x00000000) Line 4555    C++
    ProfUIS261ud.dll!CExtControlBar::InternalDockStateSite::StateSet(bool bPresetWP=true) Line 3980    C++
    ProfUIS261ud.dll!CExtControlBar::InternalFriendlyFrameWnd::SetDockState(const CExtControlBar::InternalDockStateSite & state={...}, bool bPresetWP=true) Line 3093    C++
    ProfUIS261ud.dll!CExtControlBar::ProfileBarStateSerialize(CArchive & ar={...}, CFrameWnd * pFrame=0x025f1fd8, tagWINDOWPLACEMENT * pFrameWp=0x025f4174, bool bSerializeFixedBarsState=true, bool bSerializeResizableBarsState=true, bool bEnableThrowExceptions=false) Line 5540    C++
    ProfUIS261ud.dll!CExtControlBar::ProfileBarStateLoad(CFrameWnd * pFrame=0x025f1fd8, const unsigned short * sSectionNameCompany=0x025f1f80, const unsigned short * sSectionNameProduct=0x025f0a60, const unsigned short * sSectionNameProfile=0x025f0a60, tagWINDOWPLACEMENT * pFrameWp=0x025f4174, bool bSerializeFixedBarsState=true, bool bSerializeResizableBarsState=true, HKEY__ * hKeyRoot=0x80000001, bool bEnableThrowExceptions=false) Line 2478 + 0x20    C++
    NwAnalyticsD.exe!CMainFrame::OnCreate(tagCREATESTRUCTW * lpCreateStruct=0x0012f624) Line 205 + 0x35    C++



It fails on this line:         ASSERT_VALID( m_pHelperBar );

m_pHelperBar is NULL.


If I comment out the ProfileBarStateLoad() call and just dock the toolbars, my app loads fine.

I believe I have followed the necessary steps according to the docs:

CMainFrame::CMainFrame()
{
    ::memset( &m_dataFrameWP, 0, sizeof(WINDOWPLACEMENT) );
    m_dataFrameWP.length = sizeof(WINDOWPLACEMENT);
    m_dataFrameWP.showCmd = SW_HIDE;
}

void CMainFrame::ActivateFrame(int nCmdShow)
{
    if( m_dataFrameWP.showCmd != SW_HIDE )
    {
        SetWindowPlacement(&m_dataFrameWP);
        CExtNCW < CFrameWnd >::ActivateFrame(m_dataFrameWP.showCmd);
        m_dataFrameWP.showCmd = SW_HIDE;
        return;
    }
    CExtNCW < CFrameWnd >::ActivateFrame(nCmdShow);
}


BOOL CMainFrame::DestroyWindow()
{
    TRACE("CMainFrame::DestroyWindow()\n");
    
    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(CExtControlBar::ProfileBarStateSave(
            this,
            pApp->m_pszRegistryKey,
            pApp->m_pszProfileName,
            pApp->m_pszProfileName
        )
    );

}

BOOL CNwAnalyticsApp::InitInstance()
{
...
    //pFrame->ShowWindow(SW_SHOW);
    //pFrame->UpdateWindow();
    pFrame->ActivateFrame(SW_SHOW);
return TRUE;
}


Thanks for any help.

Scott

Scott Moore Nov 27, 2006 - 8:57 AM

That isn’t the problem. I deleted the registry data and it didn’t help. Actually, I should be more specific in my error:

I have 2 toolbars in my app. Both toolbars are only displayed when certain tabs show up in the app. Both toolbars are created in the mainform and docked, but just aren’t shown until the appropriate tabs are displayed.

The 2nd toolbar seems to be the problem. If I close the app while the 2nd toolbar is displayed (the user navigated to the tab that shows it), when I restart the app - that’s when I get the error.

bEnableThrowExceptions = true does not prevent the error. Nor does it throw an exception. It just asserts. In release mode, none of my toolbars ever show up.

Technical Support Nov 27, 2006 - 12:41 PM

Would you send us a project that demonstrates the problem?

Suhai Gyorgy Nov 27, 2006 - 8:40 AM

ProfileBarStateSave method saves the last state of the toolbars and controlbars and menubar in the registry, in binary format. If, during development, you change the IDs or the number of the commands or the bars, ProfileBarStateLoad won’t be able to load the state back from the registry. But both ProfileBarStateSave and ProfileBarStateLoad now have a parameter, bEnableThrowExceptions, if you set this to true, you can catch the thrown exception and load a default state. I just usually delete the saved state from the registry when I change anything like that in my controlbars.