Solved

Multiline Tooltips in MFC

Posted on 2001-08-28
6
1,638 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
unable to delete all specified values regedit 38 155
dog bark java program 15 82
changeXy challenge 13 58
Problem to open Excel file 15 44
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: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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 tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now