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 General Discussion » How to delete some Toolbars from "FUNNYbar" example ? Collapse All
Subject Author Date
hong seok Jul 27, 2007 - 1:08 AM

I tried to eliminate the Toolbar named "m_wndToolBar256" so i commented out some lines related to "m_wndToolBar256".

But when i ran the program, it crashed with this message :::::

"Unhandled exception at 0x005fee3a (ProfUIS280ud.dll) in LedView_mi-ud.exe: 0xC0000005: Access violation reading location 0x00000000."

Please give me a hand.

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    if( CExtNCW < CFrameWnd > :: OnCreate( lpCreateStruct ) == -1 )
        return -1;

HICON hIcon = (::AfxGetApp())->LoadIcon(IDR_MAINFRAME);
    ASSERT( hIcon != NULL );
    SetIcon( hIcon, TRUE );
    SetIcon( hIcon, FALSE );

CCreateContext _cc;
    _cc.m_pCurrentDoc = NULL;
    _cc.m_pCurrentFrame = this;
    _cc.m_pLastView = NULL;
    _cc.m_pNewDocTemplate = NULL;
    _cc.m_pNewViewClass = RUNTIME_CLASS( CChildView );
CWnd * pWndView = CreateView( &_cc );
    if( pWndView == NULL )
    {
        TRACE0("Failed to create view window\n");
        return -1;
    }
    ASSERT_KINDOF( CChildView, pWndView );
CChildView * pChildView =
        STATIC_DOWNCAST( CChildView, pWndView );
    SetActiveView( pChildView );
    pWndView->ModifyStyleEx( WS_EX_CLIENTEDGE|WS_EX_STATICEDGE|WS_EX_DLGMODALFRAME, 0, SWP_FRAMECHANGED );

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

    ASSERT( pApp->m_pszProfileName != NULL );
    g_CmdManager->ProfileSetup(
        pApp->m_pszProfileName,
        GetSafeHwnd()
        );
    VERIFY(
        g_CmdManager->UpdateFromMenu(
            pApp->m_pszProfileName,
            IDR_MAINFRAME
            )
        );
    VERIFY(
        g_CmdManager->UpdateFromToolBar(
            pApp->m_pszProfileName,
            IDR_MAINFRAME
            )
        );
    /*
    VERIFY(
        g_CmdManager->UpdateFromToolBar(
            pApp->m_pszProfileName,
            IDR_TOOLBAR_SMALL_256_COLOR,
            NULL,
            NULL,
            false,
            true,
            RGB(188,190,188)
            )
        );
        */
    VERIFY(
        g_CmdManager->UpdateFromToolBar(
            pApp->m_pszProfileName,
            IDR_TOOLBAR_BIG_TRUE_COLOR
            )
        );
    VERIFY(
        g_CmdManager->UpdateFromToolBar(
            pApp->m_pszProfileName,
            IDR_TOOLBAR_VISTA_ICONS_SMALL,
            NULL,
            NULL,
            false,
            true,
            COLORREF( -1L )
            )
        );
CExtCmdItem * pCmdItem =
        g_CmdManager->CmdGetPtr(
            pApp->m_pszProfileName, ID_APP_ABOUT );
    ASSERT( pCmdItem != NULL );
    pCmdItem->m_sToolbarText = pCmdItem->m_sMenuText;
    pCmdItem->m_sToolbarText.Replace( __EXT_MFC_SAFE_LPCTSTR( _T("&") ), __EXT_MFC_SAFE_LPCTSTR( _T("") ) );

    pCmdItem =
        g_CmdManager->CmdGetPtr(
            pApp->m_pszProfileName, ID_APP_EXIT );
    ASSERT( pCmdItem != NULL );
    pCmdItem->m_sToolbarText = pCmdItem->m_sMenuText;
    pCmdItem->m_sToolbarText.Replace( __EXT_MFC_SAFE_LPCTSTR( _T("&") ), __EXT_MFC_SAFE_LPCTSTR( _T("") ) );

    
    if( !m_wndMenuBar.Create(
            NULL, // _T("Menu Bar"),
            this,
            ID_VIEW_MENUBAR
            )
        )
{
TRACE0("Failed to create menubar\n");
return -1; // failed to create
}
    
    if(        (! m_wndToolBarStd.Create(
                _T("Standard ToolBar"), this, AFX_IDW_TOOLBAR
                ) )
        ||    (! m_wndToolBarStd.LoadToolBar(IDR_MAINFRAME) )
        )
    {
        TRACE0("Failed to create standard toolbar\n");
        return -1; // fail to create
    }
    /*
    if(        (! m_wndToolBar256.Create(
                _T("256 Color (16x16 buttons)"), this, IDR_TOOLBAR_SMALL_256_COLOR
                ) )
            ||    (! m_wndToolBar256.LoadToolBar(IDR_TOOLBAR_SMALL_256_COLOR,RGB(188,190,188)) )
        )
    {
        TRACE0("Failed to create 256-color toolbar\n");
        return -1; // fail to create
    }*/

    if(        (! m_wndToolBarTrue.Create(
                _T("16777216 Color (44x40 buttons)"), this, IDR_TOOLBAR_BIG_TRUE_COLOR
                ) )
        ||    (! m_wndToolBarTrue.LoadToolBar(IDR_TOOLBAR_BIG_TRUE_COLOR) )
        )
    {
        TRACE0("Failed to create true-color toolbar\n");
        return -1; // fail to create
    }
    
    if(        (! m_wndToolBarTruePlusText.Create(
                _T("Text + 16777216 Color (44x40 buttons)"), this, IDR_TOOLBAR_BIG_TRUE_COLOR2
                ) )
        )
    {
        TRACE0("Failed to create true-color toolbar with text\n");
        return -1; // fail to create
    }
    if(        (! m_wndToolBarTrueHot.Create(
                _T("Hot + 16777216 Color (44x40 buttons)"), this, IDR_TOOLBAR_BIG_TRUE_COLOR3
                ) )
        )
    {
        TRACE0("Failed to create hot-true-color toolbar\n");
        return -1; // fail to create
    }
    if(        (! m_wndToolBarVista.Create(
                _T("Vista Icons (RGB/A 32 bits with Alpha Channel)"), this, IDR_TOOLBAR_VISTA_ICONS
                ) )
        ||    (! m_wndToolBarVista.LoadToolBar(IDR_TOOLBAR_VISTA_ICONS, COLORREF( -1L ) ) )
        )
    {
        TRACE0("Failed to create Vista Icons toolbar\n");
        return -1; // fail to create
    }
    m_wndToolBarVista.SetInitDesiredSizeFloating( CSize( 500, 100 ) );

    if(        (! m_wndToolBarUiLook.Create( NULL, this, ID_VIEW_UI_LOOK_BAR ) )
        ||    (! m_wndToolBarUiLook.ThemeSwitcherInit() )
        )
    {
        TRACE0("Failed to create Vista Icons toolbar\n");
        return -1; // fail to create
    }
    
int nCount = m_wndToolBarTrue.GetButtonsCount();
    for( int i = 0; i < nCount; i++ )
    {
        CExtBarButton * pTBB =
            m_wndToolBarTrue.GetButton( i );
        ASSERT_VALID( pTBB );
        if( pTBB->IsKindOf( RUNTIME_CLASS(CExtBarContentExpandButton) ) )
            continue;
        if( pTBB->IsSeparator() )
        {
            m_wndToolBarTruePlusText.InsertButton(
                -1,
                ID_SEPARATOR,
                FALSE
                );
            m_wndToolBarTrueHot.InsertButton(
                -1,
                ID_SEPARATOR,
                FALSE
                );
            continue;
        } // if( pTBB->IsSeparator() )
        CString strFunnyText( _T("") );
        switch( pTBB->GetCmdID() )
        {
        case ID_TRUE_FILE_NEW:
            strFunnyText = _T("New file\nentry ...");
            break;
        case ID_TRUE_FILE_OPEN:
            strFunnyText = _T("Open file\nentry ...");
            break;
        case ID_TRUE_FILE_FAVORITES:
            strFunnyText = _T("Organize\nfavorites");
            break;
        case ID_TRUE_FILE_ADD:
            strFunnyText = _T("Add\nitem");
            break;
        case ID_TRUE_FILE_EXTRACT:
            strFunnyText = _T("Extact\nfile");
            break;
        case ID_TRUE_FILE_VIEW:
            strFunnyText = _T("View\nselected");
            break;
        case ID_TRUE_FILE_CHECK_OUT:
            strFunnyText = _T("Check Out");
            break;
        case ID_TRUE_FILE_WIZARD:
            strFunnyText = _T("Wizard");
            break;
        } // switch( pTBB->GetCmdID() )
        CFunnyToolButton * pSpecTBB =
            new CFunnyToolButton(
                &m_wndToolBarTruePlusText,
                pTBB->GetCmdID(),
                (LPCTSTR)strFunnyText,
                -2.0f
                );
        m_wndToolBarTruePlusText.InsertSpecButton(
            -1,
            pSpecTBB,
            FALSE
            );
        pSpecTBB =
            new CFunnyToolButton(
                &m_wndToolBarTrueHot,
                pTBB->GetCmdID(),
                (LPCTSTR)strFunnyText,
                0.25
                );
        m_wndToolBarTrueHot.InsertSpecButton(
            -1,
            pSpecTBB,
            FALSE
            );
    } // for( int i = 0; i < nCount; i++ )
    m_wndToolBarTruePlusText.InitContentExpandButton();
    m_wndToolBarTrueHot.InitContentExpandButton();
    
    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
    }

    m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
    m_wndToolBarStd.EnableDocking(CBRS_ALIGN_ANY);
//    m_wndToolBar256.EnableDocking(CBRS_ALIGN_ANY);
    m_wndToolBarTrue.EnableDocking(CBRS_ALIGN_ANY);
    m_wndToolBarTruePlusText.EnableDocking(CBRS_ALIGN_ANY);
    m_wndToolBarTrueHot.EnableDocking(CBRS_ALIGN_ANY);
    m_wndToolBarVista.EnableDocking(CBRS_ALIGN_ANY);
    m_wndToolBarUiLook.EnableDocking(CBRS_ALIGN_ANY);
    
    if( !CExtControlBar::FrameEnableDocking(this) )
    {
        ASSERT( FALSE );
        return -1;
    }

    if(    !CExtControlBar::ProfileBarStateLoad(
            this,
            pApp->m_pszRegistryKey,
            pApp->m_pszProfileName,
            pApp->m_pszProfileName,
            &m_dataFrameWP
            )
        )
    {
        DockControlBar( &m_wndMenuBar, AFX_IDW_DOCKBAR_TOP );
        DockControlBar( &m_wndToolBarStd, AFX_IDW_DOCKBAR_TOP );
    //    DockControlBar( &m_wndToolBar256, AFX_IDW_DOCKBAR_TOP );
        DockControlBar( &m_wndToolBarTrue, AFX_IDW_DOCKBAR_LEFT );
        DockControlBar( &m_wndToolBarTruePlusText, AFX_IDW_DOCKBAR_BOTTOM );
        DockControlBar( &m_wndToolBarTrueHot, AFX_IDW_DOCKBAR_TOP );
        FloatControlBar( &m_wndToolBarVista, CPoint(300,300) );
        DockControlBar( &m_wndToolBarUiLook, AFX_IDW_DOCKBAR_RIGHT );
    }
    RecalcLayout();
    


    return 0;
}

hong seok Jul 30, 2007 - 6:26 PM

I really appreciate your sincere answer. Now I know why the program crashed. The problem had to do with registry.

Thanks a lot.

Technical Support Jul 28, 2007 - 12:08 PM

It seems you incompletely removed all the code related to the m_wndToolBar256 toolbar. The code you show is of little use. We could only help you if you sent us the entire project.

Suhai Gyorgy Jul 27, 2007 - 1:27 PM

You can download a modified version of FunnyBars from here.
I changed MainFrm.h, MainFrm.cpp, Resource.h and FunnyBars.rc files. All changes are flagged by a //rem comment (if it is a block of code, only first and last lines are flagged). To run it without crash, you have to remove saved state of command manager and control bars from registry.