Solved

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

Posted on 1998-12-17
4
1,766 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
  • 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

770 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