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 » Is it possible to add tooltips to an existing toolbar? Collapse All
Subject Author Date
Scott Moore Dec 20, 2006 - 9:09 AM

I have an existing toolbar that I would like to add tooltips to. But I can’t figure out how to do it. I looked at some sample code, but it’s doing things with CExtCustomizeSite that I haven’t a clue about. I really can’t begin to figure out how to integrate CExtCustomizeSite into an existing app.

Is there an easy way to add tooltips to each button in my CExtToolControlBar?

Technical Support Dec 21, 2006 - 11:22 AM

The toolbar button tooltips in both customizable and non-customizable applications are not properties of toolbar buttons. The tooltips are properties of the command objects stored in the command manager:

CExtToolControlBar & wndToolBar = . . .
INT nButtonIndex = . . .
CExtBarButton * pTBB = wndToolBar.GetButton( nButtonIndex );
    if( pTBB == NULL )
        return . . . // if nButtonIndex specifies invalid index
    ASSERT_VALID( pTBB );
    if( pTBB->IsSeparator() )
        return . . . // if toolbar button at nButtonIndex position is separator
UINT nCommandID = pTBB->GetCmdID( false );
    if( ! nCommandID::IsCommand( nCommandID ) )
        return . . . // if some specific toolbar button
CExtCmdItem * pCmdItem = g_CmdManager->CmdGetPtr( g_CmdManager->ProfileNameFromWnd( wndToolBar.GetSafeHwnd() ), nCommandID );
    if( pCmdItem == NULL )
        return . . . // if command is not registered in the command manager (normally this should not occur)
    pCmdItem->m_sTipTool = _T("This is the tooltip text");

Scott Moore Dec 20, 2006 - 10:58 AM

Ah, okay. My toolbar has more than 16 colors, so I had to edit the string table directly, but thanks for the help.

I have another question regarding toolbars in our application. We create 2 toolbars in our application:


    if ( !m_wndContentViews.Create( L"Content Toolbar", this, AFX_IDW_TOOLBAR,
        WS_CHILD | CBRS_RIGHT | CBRS_GRIPPER | CBRS_FLYBY | CBRS_SIZE_DYNAMIC | CBRS_TOOLTIPS ) ||
        !m_wndContentViews.LoadToolBar( IDR_CONTENT_VIEWS ) )
    {
        TRACE0("Failed to create content view toolbar\n");
        return -1; // failed to create
    }

    m_wndContentViews.EnableDocking( CBRS_ALIGN_ANY );

    if ( !m_wndCollectionToolbar.Create(L"Collection Toolbar", this, AFX_IDW_TOOLBAR,
        WS_CHILD | CBRS_RIGHT | CBRS_GRIPPER | CBRS_FLYBY | CBRS_SIZE_DYNAMIC | CBRS_TOOLTIPS ) ||
        !m_wndCollectionToolbar.LoadToolBar( IDR_COLLECTION_TOOLBAR ) )
    {
        TRACE0("Failed to create collection tab toolbar\n");
        return -1; // failed to create
    }

    m_wndCollectionToolbar.EnableDocking( CBRS_ALIGN_ANY );


We initially hide both toolbars and only display them when certain tabs are displayed in our tab container. However if you right click the toolbar, you get a menu that looks like this:

Toolbar
Toolbar

However, no matter which menu item you select, it only controls m_wndContentViews. No option exists for our 2nd toolbar. Furthermore, on the View menu, there’s only one Toolbar menu item and it only controls wndContentViews.

How can we either fix the menu so it works correctly or just remove the toolbars from all menus (popup and View).

Suhai Gyorgy Dec 21, 2006 - 1:53 AM

The problem is the 3rd parameter of the Create method. It should be an ID which identifies the created toolbar. You have to use a different ID for each and every toolbar.

You can exclude any control bar (toolbar, menu bar, control bar, or panel bar) from the menu with the list of all control bars created in the frame window using this code:

m_wndBar.m_bAppearInDockSiteControlBarPopupMenu = false;

Technical Support Dec 20, 2006 - 9:57 AM

You can specify tooltip and status tip text for each command in the toolbar resources (the Promt field in the resource editor).


Tooltip Text


There is an article Prof-UIS Customization Subsystem that can be a good starting point for getting started with CExtCustomizeSite.