Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

610 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