Solved

Multiline Tooltips in MFC

Posted on 2001-08-28
6
1,698 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
[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
  • 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
Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

 
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

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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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 brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses

628 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