Print Page | Close Window

Reset tooltip

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=22588
Printed Date: 24 November 2024 at 12:56pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Reset tooltip
Posted By: maxxan
Subject: Reset tooltip
Date 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? 



Replies:
Posted By: rdhd
Date 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 );
                            }
                        }
                    }
                }
            }
        }

    }
}




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net