Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Multiline Tooltips in MFC

Posted on 2001-08-28
6
Medium Priority
?
1,730 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 49

Accepted Solution

by:
DanRollins earned 200 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

722 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