?
Solved

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

Posted on 1998-12-17
4
Medium Priority
?
1,866 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 400 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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 this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Suggested Courses
Course of the Month13 days, 8 hours left to enroll

800 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