Solved

Multiline Tooltips in MFC

Posted on 2001-08-28
6
1,660 Views
Last Modified: 2013-11-20
How do I create a tooltip that has multiple lines of text in MFC
0
Comment
Question by:WarrenW
  • 4
6 Comments
 
LVL 49

Expert Comment

by:DanRollins
ID: 6432314
Add this to your CMainFrame message map

    ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipText)
    ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipText)

Add this fn to CMainFrame (and a prototyp in the header)

BOOL CMainFrame::OnToolTipText( UINT id, NMHDR * pNMHDR, LRESULT * pResult )
{
     static CToolTipCtrl* pToolTip = NULL;
     CToolTipCtrl* ptt= AfxGetThreadState()->m_pToolTip;
     if (ptt != pToolTip) { // new tooltip
         CRect rc(4,4,4,4); // 4 pixel margin
         ptt->SetMargin(&rc);
         ptt->SetTipBkColor( RGB(128,255,128));
         ptt->SetMaxTipWidth(128);
         ptt->SetDelayTime(TTDT_AUTOPOP, SHRT_MAX);
         pToolTip = ptt;
     }
     return CFrameWnd::OnToolTipText(id, pNMHDR, pResult);
}

Now edit the resource string section.  For instance, see...

ID_FILE_NEW   57600  Create a new document\nNew
and chang to...
ID_FILE_NEW   57600  Create a new document\nNew AND IMPROVED and MUCH longer then ever before!

In MSDN, look up the article:
Visual C++ 6.0 Brings Home a Full Bag of Tricks and Treats for MFC Developers

for more info
-==-=-=-=-=-=-=-=-=-=-=-=-=-
Here's a BONUS!
  ptt->ModifyStyle(0, 0x0040); // TTS_BALLOON = 0x0040, but not in the header

makes cool "comic book talk" baloons intead of a rectangle.

-- Dan
0
 
LVL 3

Expert Comment

by:cypherljk
ID: 6434255
..listening
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6448370
hi WarrenW,
Do you have any additional questions?  Do any comments need clarification?

-- Dan
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 49

Accepted Solution

by:
DanRollins earned 50 total points
ID: 6480661
hi WarrenW,
Do you have any additional questions?  Do any comments need clarification?

-- Dan
0
 

Expert Comment

by:BobbyBoomBox
ID: 30062105
I receive this error when trying to do this:

error C2039: 'm_pToolTip' : is not a member of '_AFX_THREAD_STATE'
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 30063612
Hi BobbyBoomBox,
This is a nine year old question.  I suggest that you ask a new question.  Click the Ask A Related Question link,  just above the comment box.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Suggested Solutions

Title # Comments Views Activity
bigDiff challenge 17 126
fix34  challenge 9 148
wordmultiple challenge 12 142
"Black Box" Testing of Control System Software 2 72
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
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…
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

820 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