Print Page | Close Window

Set tooltip text and description dynamically

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=15858
Printed Date: 04 June 2025 at 2:23am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Set tooltip text and description dynamically
Posted By: iftekhar
Subject: Set tooltip text and description dynamically
Date Posted: 15 December 2009 at 7:26am
Hi,
 
I am working with CXTPCommandBars, which I use to create menubar and toolbar from frame and dialog window. I would like to set tooltip text and description dynamically when the mouse hovers on the toolbar controls.
 
I am using xtpToolTipLuna stype for the tool tip. I did the following to change the style of the tooltip.
 
 
void CSwToolTipCtrl::UpdateToolTipStyle(CXTPCommandBars* pCommandBars)
{
    if (!pCommandBars)
       return;
    pCommandBars->GetCommandBarsOptions()->bShowPopupBarToolTips = TRUE;
    if (CSwToolTipCtrl::m_nToolTipMode == TOOLTIP_MODE_NOVICE)
       pCommandBars->GetCommandBarsOptions()->ShowKeyboardCues(xtpKeyboardCuesShowWindowsDefault);
    pCommandBars->GetToolTipContext()->SetStyle(xtpToolTipLuna);
    pCommandBars->GetToolTipContext()->ShowTitleAndDescription(CSwToolTipCtrl::m_nToolTipMode == TOOLTIP_MODE_NOVICE);
    pCommandBars->GetToolTipContext()->ShowImage(TRUE);
}
 
 
But the tooltip text is loaded from the resource which I don't want and provide my own text and description. The text and description is provided based on the id of the control. Therefore when the mouse hover on a control I have to call SetDescription("Text") for that CXTPControl. But I might need a callback function or message handler to where I can do this. I tried OnToolTipText which is not getting called for CXTPCommandBars unlike standard MFC and OnToolHitTest which I did not have much luck with.
 
Could anybody please shed some light on it and tell me how I can do this?
 
Thanks in advance
 
Iftekhar


-------------
IAT



Replies:
Posted By: Oleg
Date Posted: 16 December 2009 at 5:32am
Hi,
 
You can catch WM_XTP_CONTROLSELECTED message. if wParam is not NULL it will point to new selected control.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: iftekhar
Date Posted: 16 December 2009 at 7:00am

Thanks Oleg. I tried this and it works. But this message is send once the tooltip is displayed. Therefore the first time I select a control the old tool tip is displayed then the WM_XTP_CONTROLSELECTED is handled. Then when I select the control second time the tooltip set for the control in WM_XTP_CONTROLSELECTED handler function is displayed. I tried setting an initial tool tip ON_XTP_AFTERCREATECONTROL() but that is no help to me because the user can change the tool tip mode after the controls are created at runtime which brings me to square one again. So is there any other message like WM_XTP_CONTROLSELECTED which is handled before tool tip is displayed.

 

Regards

 

Iftekhar



-------------
IAT



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