Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - Reset tooltip
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Reset tooltip

 Post Reply Post Reply
Author
Message
maxxan View Drop Down
Groupie
Groupie


Joined: 15 July 2009
Status: Offline
Points: 49
Post Options Post Options   Thanks (0) Thanks(0)   Quote maxxan Quote  Post ReplyReply Direct Link To This Post Topic: Reset tooltip
    Posted: 30 April 2015 at 3:39am
Is it possible to not load tooltip info when loading customized ribbons or to reset only tooltips?

The problem is that then creating the ribbons, the tooltip is different depending on which license you have for the application. But this is not reflected in the button tooltip, since it loads button customizations etc., so it's not visible until I reset the ribbons.

How to solve this, to use different tooltip when creating the ribbon and it becomes visible for the buttons? 
Back to Top
rdhd View Drop Down
Senior Member
Senior Member
Avatar

Joined: 13 August 2007
Location: United States
Status: Offline
Points: 886
Post Options Post Options   Thanks (0) Thanks(0)   Quote rdhd Quote  Post ReplyReply Direct Link To This Post Posted: 02 October 2015 at 12:37pm
We do this for the same purpose - licensing. We show a different tip based on the license (as in - "This is a wonderful command, but you don't have a license to use it." sort of string).

After we load the ribbon, we get the controls collection and spin through all the controls, get each ID and do a license check and modify the tooltip text, description etc. based on the license. We also have to get the QuickAccess control and run through its controls and change the tip data there too. We do that because we use CJ to save the QAT out for customization purposes and the tooltip is saved too. Here is some code. Note we have our own tooltip system and we use the Description for the actual tip and the tooltip text as a title. So this code only changes the description.


void JCXTPRibbonBar::SetToolTipForUnlicensedCommands()
{
    CXTPControls* pControls = GetControls();

    CString strUnLicensed = GetLicenseNotAvailableTooltipString();

    GUserText gutEnv = m_strEnvironment;

    if( pControls )
    {
        int nNumControls = pControls->GetCount();

        for( int Index = 0; Index < nNumControls; ++Index )
        {
            CXTPControl* pControl = pControls->GetAt( Index );
            if( pControl )
            {
                if( !JIsCommandLicensed((LPCSTR)gutEnv,pControl->GetID() ) )
                {
                    // Yes I know the function is SetToolTipForUnlicensedCommands and that I am not calling SetToolTip on the
                    // control but rather am setting the Description. But that's because we use the description as the tip and
                    // the tip as the title.
                    pControl->SetDescription( strUnLicensed );
                }
            }
        }

        // for customization and any tip that is present is saved out and read back in.
        if (CXTPRibbonQuickAccessControls* pQAControls = GetQuickAccessControls())
        {
            JFrameWnd* pFrame = (JFrameWnd*)JGetMainCFrameWnd30();

            if( pFrame )
            {
                int nControls = pQAControls->GetCount();
                for (int nControl = 0; nControl < nControls; ++nControl)
                {
                    if (CXTPControl* pControl = pQAControls->GetAt(nControl))
                    {
                        if( JIsCommandLicensed((LPCSTR)gutEnv,pControl->GetID() ) )
                        {
                            CString strMessage;

                            pFrame->GetMessageString(pControl->GetID(), strMessage );

                            if( !strMessage.IsEmpty() )
                            {
                                pControl->SetDescription( strMessage );
                            }
                        }
                    }
                }
            }
        }

    }
}

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.204 seconds.