Solved

Multiline Tooltips in MFC

Posted on 2001-08-28
6
1,675 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
Industry Leaders: 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!

 
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

Suggested Solutions

Title # Comments Views Activity
Login Script to Copy Folders 12 51
Include multiple hostnames in this command? 3 56
Installing Microsoft R server on REDHAT or SUSE Linux 4 162
sumNumber challenge 16 147
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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…
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.

751 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