Solved

How to use CToolTipCtrl class to display my own tool tips?

Posted on 1998-12-17
4
1,791 Views
Last Modified: 2013-11-20
I need to display different messages which dinamically change and are not set in resources.  I need to do this when mouse pointer moves over a certain area of a dialog.
I declare local CToolTipCtrl variable, create tool tip control and than I try different ways to display my message; unsuccessfuly.

I'd appreciate any suggestions.

Seweryn S. Makosa
0
Comment
Question by:nyrewes
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 

Author Comment

by:nyrewes
ID: 1326362
Edited text of question
0
 

Author Comment

by:nyrewes
ID: 1326363
Edited text of question
0
 
LVL 8

Accepted Solution

by:
Answers2000 earned 200 total points
ID: 1326364
Use AddTool/UpdateTipText to change the text.  You can pass a string or resource id.  This function is overloaded (there are 2 versions : look it up in the help)

Presumably you are doing the relay events stuff

The steps are :-
1. Add tooltip member variable (CToolTipCtrl) to your dialog class, say m_ToolTip
2. OnInitDialog do
      // set tooltips
      m_ToolTip.Create (this);
            m_ToolTip.Activate (TRUE);
            m_ToolTip.AddTool( &m_btnPrev, IDS_TTPREV ) ;
            m_ToolTip.AddTool( &m_btnNext, IDS_TTNEXT ) ;
            m_ToolTip.AddTool( &m_btnFirst, "Some Text" ) ;

The first parameter of the control is the CWnd (or derived from CWnd - example:CButton,CEdit etc) from the control you want to associate the tip with, second is the resource id, or there's an overloaded version of AddTool which takes a string parameter

3. PreTranslate message
BOOL CTComply::PreTranslateMessage(MSG* pMsg)
{
    if (m_hWnd)    
      {
        m_ToolTip.RelayEvent (pMsg);
            return CDialog::PreTranslateMessage(pMsg);
      }
    return (FALSE);
            
}


4. For an area on a dialog containing no visible controls, I suggest you create  a dummy static control at the correct location, and bind a CStatic member variable to it.  If the dummy control has no text, it will be invisible to the user, so it will look like the tooltip comes from the dialog background.
0
 
LVL 31

Expert Comment

by:Zoppo
ID: 1326365
You can set text of tooltips dynamically at runtime in a TTN_NEEDTEXT message handler.

hope that helps
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MFC Dialog 9 53
Creating Labels and Frequency list style reports in SAS code 9 113
either24  challenge 19 105
Problem to App source 6 93
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question