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 » Debug Assertion Failed in ExtControlBar.cpp Collapse All
Subject Author Date
HeeTae Lee Jan 29, 2007 - 5:06 PM

I made my project like SDIDOCVIEW example.

When I tried to remove the color picker control bar at my project, "Debug Assertion Failed" error happened.

I changed the code at "OnCreate" function in Mainframe.cpp as below:

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’) );

    if( CExtNCW < CFrameWnd > :: OnCreate( lpCreateStruct ) == -1 )
    {
        ASSERT( FALSE );
        return -1;
    }

    VERIFY(
        g_CmdManager->ProfileWndAdd(
            pApp->m_pszProfileName,
            GetSafeHwnd()
            )
        );
    VERIFY(
        g_CmdManager->UpdateFromMenu(
            pApp->m_pszProfileName,
            IDR_MAINFRAME
            )
        );

    if(    !m_wndMenuBar.Create(
            NULL,
            this,
            ID_VIEW_MENUBAR
            )
        )
{
TRACE0("Failed to create menubar\n");
return -1; // failed to create
}
    
    if(        (! m_wndToolBar.Create( NULL, this, AFX_IDW_TOOLBAR ) )
        ||    (! m_wndToolBar.LoadToolBar( IDR_MAINFRAME ) )
        )
    {
        TRACE0("Failed to create the m_wndToolBar toolbar\n");
        return -1; // fail to create
    }

    if(        (! m_wndToolBarUiLook.Create( NULL, this, ID_VIEW_UI_LOOK_BAR ) )
        ||    (! m_wndToolBarUiLook.ThemeSwitcherInit() )
        )
    {
        TRACE0("Failed to create the m_wndToolBarUiLook toolbar\n");
        return -1; // fail to create
    }

    if(        (! m_wndStatusBar.Create( this ) )
        ||    (! m_wndStatusBar.SetIndicators(
                indicators,
                sizeof(indicators) / sizeof(UINT)
                )
            )
        )
    {
        TRACE0("Failed to create status bar\n");
        return -1; // fail to create
    }
//
// Start of modification
//
    if( !m_wndTreeMenu.Create(
        _T("Tree Menu"),
        this,
        ID_VIEW_RESIZABLEBAR_EMPTY
            )
        )
    {
        TRACE0("Failed to create m_wndTreeMenu\n");
        return -1;
    }

    m_wndFlatTabPageContainer0.Create( &m_wndTreeMenu );

    InitTreeCtrl(&m_wndTreeCtrl0, &m_wndFlatTabPageContainer0);
    InitTreeCtrl(&m_wndTreeCtrl1, &m_wndFlatTabPageContainer0);
    InitTreeCtrl(&m_wndTreeCtrl2, &m_wndFlatTabPageContainer0);

    HICON hIcon;

    hIcon = (HICON)::LoadImage( ::AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_SHORTCUTS_SMALL),
        IMAGE_ICON, 16, 16, 0);
    VERIFY( m_wndFlatTabPageContainer0.PageInsert( &m_wndTreeCtrl0, _T("Modelling"), hIcon, true));
    hIcon = (HICON)::LoadImage( ::AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_NOTES_SMALL),
        IMAGE_ICON, 16, 16, 0);
    VERIFY( m_wndFlatTabPageContainer0.PageInsert( &m_wndTreeCtrl1, _T("Analysis"), hIcon, true));
    hIcon = (HICON)::LoadImage( ::AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_CONTACTS_SMALL),
        IMAGE_ICON, 16, 16, 0);
    VERIFY( m_wndFlatTabPageContainer0.PageInsert( &m_wndTreeCtrl2, _T("Post Processor"), hIcon, true));

    m_wndFlatTabPageContainer0.SelectionBoldSet();
    m_wndFlatTabPageContainer0.OrientationSet(__ETWS_ORIENT_BOTTOM);
//
// End of Modification
//
    m_wndResizableBarTree.SetInitDesiredSizeVertical(
        CSize( 200, 400 )
        );
    m_wndResizableBarTree.SetInitDesiredSizeHorizontal(
        CSize( 400, 200 )
        );
    if(    !m_wndResizableBarTree.Create(
            NULL, // _T("Optional control bar caption"),
            this,
            ID_VIEW_RESIZABLEBAR_TREE
            )
        )
    {
        TRACE0("Failed to create m_wndResizableBarTree\n");
        return -1;        // fail to create
    }
    if( !m_wndDockedCtrlTree.Create(
            WS_CHILD|WS_VISIBLE|WS_VSCROLL|WS_HSCROLL
            |TVS_HASBUTTONS|TVS_HASLINES|TVS_LINESATROOT
            |TVS_INFOTIP|TVS_DISABLEDRAGDROP
            |TVS_SINGLEEXPAND|TVS_SHOWSELALWAYS
            ,
            CRect(0,0,0,0),
            &m_wndResizableBarTree,
            m_wndResizableBarTree.GetDlgCtrlID()
            )
        )
    {
        TRACE0("Failed to create m_wndDockedCtrlEdit\n");
        return -1;        // fail to create
    }
    m_wndDockedCtrlTree.SetFont(
        CFont::FromHandle(
            (HFONT)::GetStockObject(DEFAULT_GUI_FONT)
            )
        );
    for( int nTreeIdx0=0; nTreeIdx0<10; nTreeIdx0++ )
    {
        CString sTreeItemText;
        sTreeItemText.Format( _T("Item 1-%d"), nTreeIdx0+1 );
        HTREEITEM htiAtLevel0 =
            m_wndDockedCtrlTree.InsertItem(
            LPCTSTR(sTreeItemText)
            );
        ASSERT( htiAtLevel0 != NULL );
        for( int nTreeIdx1=0; nTreeIdx1<5; nTreeIdx1++ )
        {
            sTreeItemText.Format( _T("Item 2-%d"), nTreeIdx1+1 );
            HTREEITEM htiAtLevel1 =
                m_wndDockedCtrlTree.InsertItem(
                    LPCTSTR(sTreeItemText),
                    htiAtLevel0
                    );
            ASSERT( htiAtLevel1 != NULL );
            for( int nTreeIdx2=0; nTreeIdx2<3; nTreeIdx2++ )
            {
                sTreeItemText.Format( _T("Item 3-%d"), nTreeIdx2+1 );
                HTREEITEM htiAtLevel2 =
                    m_wndDockedCtrlTree.InsertItem(
                        LPCTSTR(sTreeItemText),
                        htiAtLevel1
                        );
                ASSERT( htiAtLevel2 != NULL );
                htiAtLevel2;
            } // for( int nTreeIdx2=0; nTreeIdx2<5; nTreeIdx2++ )
        } // for( int nTreeIdx1=0; nTreeIdx1<5; nTreeIdx1++ )
    } // for( int nTreeIdx0=0; nTreeIdx0<10; nTreeIdx0++ )

    m_wndResizableBarEdit.SetInitDesiredSizeVertical(
        CSize( 200, 400 )
        );
    m_wndResizableBarEdit.SetInitDesiredSizeHorizontal(
        CSize( 400, 200 )
        );
    if(    !m_wndResizableBarEdit.Create(
            NULL, // _T("Optional control bar caption"),
            this,
            ID_VIEW_RESIZABLEBAR_EDIT
            )
        )
    {
        TRACE0("Failed to create m_wndResizableBarEdit\n");
        return -1;        // fail to create
    }
    if( !m_wndDockedCtrlEdit.Create(
            WS_CHILD|WS_VISIBLE
                |ES_MULTILINE|ES_LEFT
                |ES_NOHIDESEL|ES_WANTRETURN
                ,
            CRect(0,0,0,0),
            &m_wndResizableBarEdit,
            m_wndResizableBarEdit.GetDlgCtrlID()
            )
        )
    {
        TRACE0("Failed to create m_wndDockedCtrlEdit\n");
        return -1;        // fail to create
    }
    m_wndDockedCtrlEdit.SetFont(
        CFont::FromHandle(
            (HFONT)::GetStockObject(DEFAULT_GUI_FONT)
            )
        );
    m_wndDockedCtrlEdit.SetWindowText(
        _T(" Edit control\r\n")
        _T(" inside resizable control bar")
        );
/*
    m_wndResizableBarCP.SetInitDesiredSizeVertical(
        CSize( 200, 400 )
        );
    m_wndResizableBarCP.SetInitDesiredSizeHorizontal(
        CSize( 400, 200 )
        );
    if(    !m_wndResizableBarCP.Create(
            NULL, // _T("Optional control bar caption"),
            this,
            ID_VIEW_RESIZABLEBAR_CP
            )
        )
    {
        TRACE0("Failed to create m_wndResizableBarCP\n");
        return -1;        // fail to create
    }
    if( !m_wndDockedCtrlCP.Create(
            _T("BUTTON"),
            _T(""),
            WS_CHILD|WS_VISIBLE,
            CRect(0,0,0,0),
            &m_wndResizableBarCP,
            m_wndResizableBarCP.GetDlgCtrlID()
            )
        )
    {
        TRACE0("Failed to create m_wndDockedCtrlCP\n");
        return -1;        // fail to create
    }
*/
    m_wndResizableBarDlg.SetInitDesiredSizeVertical(
        CSize( 200, 400 )
        );
    m_wndResizableBarDlg.SetInitDesiredSizeHorizontal(
        CSize( 400, 200 )
        );
    if(    !m_wndResizableBarDlg.Create(
            NULL, // _T("Optional control bar caption"),
            this,
            ID_VIEW_RESIZABLEBAR_DLG
            )
        )
    {
        TRACE0("Failed to create m_wndResizableBarDlg\n");
        return -1;        // fail to create
    }
    if( !m_wndDockedResizableDialog.Create(
            IDD_DIALOG_FOR_RESIZABLE_BAR,
            &m_wndResizableBarDlg
            )
        )
    {
        TRACE0("Failed to create m_wndResizableBarDlg\n");
        return -1;        // fail to create
    }
    m_wndDockedResizableDialog.ShowSizeGrip( FALSE );
    m_wndDockedResizableDialog.AddAnchor(
        IDC_EDIT_IN_RESIZABLE_FORM,
        __RDA_LT,
        __RDA_RT
        );
    VERIFY(
            m_wndEditInDockedDlg.SubclassDlgItem(
                IDC_EDIT_IN_RESIZABLE_FORM,
                &m_wndDockedResizableDialog
                )
        &&    m_wndLableInDockedDlg.SubclassDlgItem(
                IDC_STATIC1,
                &m_wndDockedResizableDialog
                )
        );

    m_wndMenuBar.EnableDocking( CBRS_ALIGN_ANY );
    m_wndToolBar.EnableDocking( CBRS_ALIGN_ANY );
    m_wndToolBarUiLook.EnableDocking( CBRS_ALIGN_ANY );
    m_wndTreeMenu.EnableDocking( CBRS_ALIGN_ANY );
    m_wndResizableBarTree.EnableDocking( CBRS_ALIGN_ANY );
    m_wndResizableBarEdit.EnableDocking( CBRS_ALIGN_ANY );
//    m_wndResizableBarCP.EnableDocking( CBRS_ALIGN_ANY );
    m_wndResizableBarDlg.EnableDocking( CBRS_ALIGN_ANY );

    //
    // Prof-UIS advanced docking windows feature:
    // Show content of control bars when docking / resizing
    //
    if( !CExtControlBar::FrameEnableDocking(this) )
    {
        ASSERT( FALSE );
        return -1;
    }
    
#if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
    if( !CExtControlBar::FrameInjectAutoHideAreas(this) )
    {
        ASSERT( FALSE );
        return -1;
    }
#endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)


static UINT statBasicCommands[] =
{
    ID_FILE_NEW,
    ID_FILE_OPEN,
    ID_FILE_SAVE,
    ID_APP_EXIT,
    ID_APP_ABOUT,
    ID_FILE_PRINT,
    ID_FILE_PRINT_SETUP,
    ID_EDIT_COPY,
    ID_EDIT_CUT,
    ID_EDIT_PASTE,
    ID_EDIT_UNDO,
    ID_VIEW_TOOLBAR,
    ID_VIEW_UI_LOOK_BAR,
    ID_VIEW_RESIZABLEBAR_EMPTY,
    ID_VIEW_RESIZABLEBAR_TREE,
    ID_VIEW_RESIZABLEBAR_EDIT,
    ID_VIEW_RESIZABLEBAR_DLG,
    0 // end of commands list
}; // statBasicCommands array

    VERIFY(
        g_CmdManager->SetBasicCommands(
            pApp->m_pszProfileName,
            statBasicCommands
            )
        );
    g_CmdManager->SerializeState(
        pApp->m_pszProfileName,
        pApp->m_pszRegistryKey,
        pApp->m_pszProfileName,
        false
        );

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

        m_wndTreeMenu.FloatControlBar(
            CPoint( 40, 100 )
            );
        m_wndResizableBarTree.FloatControlBar(
            CPoint( 300, 100 )
            );
        m_wndTreeMenu.DockControlBar(
            &m_wndResizableBarEdit,
            true,
            true,
            this,
            true
            );
//        m_wndResizableBarCP.FloatControlBar(
//            CPoint( 360, 170 )
//            );
//        m_wndResizableBarCP.DockControlBar(
//            &m_wndResizableBarDlg,
//            false,
//            true,
//            this,
//            true
//            );
    }

    m_wndFlatTabPageContainer0.SetSize(25);
    m_wndFlatTabPageContainer0.SetShift(0);
    m_wndFlatTabPageContainer0.PageSelectionSet(0);

    return 0;

The error message indicates that

File:C:\ProgramFiles\FOSS Software Inc\Prof-UIS=ExtControlBar.cpp
Line : 4592

How can I fix the error?

Suhai Gyorgy Jan 30, 2007 - 1:37 AM

The sample saves the state and position of its controlbars in the registry in binary format. When the color picker control bar was still in the project, ProfileBarStateSave method saved these data in the registry. Then you removed the control bar and ran the project again. At the end of CMainFrame::OnCreate there’s a call ProfileBarStateLoad. This method tries to load the saved state from registry, but this data contains information about the color control picker bar as well. The debug assertion shows that ProfileBarStateLoad failed to load the state because data about color control picker bar couldn’t be handled.

Solution1: Delete the appropiate registry keys from registry,
Solution2: Run sample in release mode once. Release mode won’t throw assertion on ProfileBarStateLoad and saves the right state when closing the application,
Solution3: Starting from version 2.51, there is a bEnableThrowExceptions parameter for ProfileBarStateLoad that you can set to false and avoid throwing exception in this case. Check Help file.