Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

multi line tool tips

Posted on 2000-03-27
4
Medium Priority
?
371 Views
Last Modified: 2013-11-20
Using tool tips code (TipText "here is what to do"), how would I make the tool tip multi line. If I put \n\r I get a bar in the program. If I just type in a long tool tip then the progam crashes. This should be fairly easy to answer. I am using Visual C++ 6
Thanks
Louise
0
Comment
Question by:c_louise
  • 2
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
derekcmartin earned 100 total points
ID: 2661666
THIS WAS TAKEN FROM MSDN LIBRARY

Multiline Tooltips
Multiline tooltip support allows text to be displayed on more than one line. This feature is useful if your message is too lengthy to be easily read as a single line of text. The following example shows a multiline tooltip that is displayed when the cursor hovers over the Internet Explorer icon on the desktop.

 
Creating Multiline Tooltips
Your application creates a multiline tooltip by responding to a TTN_GETDISPINFO notification message. To force the tooltip control to use multiple lines, send a TTM_SETMAXTIPWIDTH message, specifying the width of the display rectangle. Text that exceeds this width will wrap to the next line rather than widening the display region. The rectangle height will be increased as needed to accommodate the additional lines. The tooltip control will wrap the lines automatically, or you can use a carriage return/line feed combination, "\r\n", to force line breaks at particular locations.

Note that the text buffer specified by the szText member of the NMTTDISPINFO structure can only accommodate 80 characters. If you need to use a longer string, point the lpszText member of NMTTDISPINFO to a buffer containing the desired text.

The following code fragment is an example of a simple TTN_GETDISPINFO notification handler. It creates a multiline tooltip by setting the display rectangle to 300 pixels and setting the lpszText member of NMTTDISPINFO to point to a buffer with the desired text.

char szLongMessage[] =
"This is a long message for the tooltip, which will automatically "
"be wrapped when it exceeds the maximum tip width.  "
"Alternatively, you can use a \r\n"
"carriage return/line feed combination\r\n"
"to force line breaks at specific\r\n"
"locations.";

switch (lpnmhdr->code) {
  case TTN_GETDISPINFO:
    lpttd = (LPNMTTDISPINFO)lpnmhdr;
    SendMessage(lpnmhdr->hwndFrom, TTM_SETMAXTIPWIDTH, 0, 300);
    lpttd->lpszText = szLongMessage;
    return 0;
      
      ...
 //Other notification handlers go here, as needed.
}
0
 

Author Comment

by:c_louise
ID: 2663970
I still need more explanation on how to get it to work with my code. Here is a piece of code from my program.TOOLTIPTEXT *TipText = ( TOOLTIPTEXT * ) pNMHDR;
            UINT nID = pNMHDR->idFrom;

      if ( TipText->uFlags & TTF_IDISHWND )
      {
      nID = ::GetDlgCtrlID((HWND)nID);
      switch( nID )
      {
      case IDC_BADDNAME:
            strcpy(TipText->szText,"Click to Add new addresses");
            break;
      case IDC_ADDRESSDELETE:
            strcpy(TipText->szText,"Deletes the highlighted names");
            break;
      case IDC_BSTOP:
            strcpy(TipText->szText, "Click to exit the screen");
            break;
Where would I put the code for the multiline tip.

Thanks
Louise
0
 
LVL 1

Expert Comment

by:derekcmartin
ID: 2664141
Louise,
     Try this:

char szLongMessage[] =
"This is a long message for the tooltip, which will automatically " 
"be wrapped when it exceeds the maximum tip width.  "
"Alternatively, you can use a \r\n"
"carriage return/line feed combination\r\n"
"to force line breaks at specific\r\n"
"locations.";


TOOLTIPTEXT *TipText = ( TOOLTIPTEXT * ) pNMHDR;
UINT nID = pNMHDR->idFrom;

if ( TipText->uFlags & TTF_IDISHWND )
{
nID = ::GetDlgCtrlID((HWND)nID);
switch( nID )
{
case IDC_BADDNAME:
strcpy(TipText->szText,"Click to Add new addresses");
break;
case IDC_ADDRESSDELETE:
strcpy(TipText->szText,"Deletes the highlighted names");
break;
case IDC_BSTOP:
strcpy(TipText->szText, "Click to exit the screen");
default:
    lpttd = (LPNMTTDISPINFO)lpnmhdr;
    SendMessage(lpnmhdr->hwndFrom, TTM_SETMAXTIPWIDTH, 0, 300);
    lpttd->lpszText = szLongMessage;
break;

0
 

Author Comment

by:c_louise
ID: 2664299
I changed a few things to better suit my code, because I was getting errors, when it could not find lpttd and lpnmhdr, I made the default like this

default:
            TipText = (LPNMTTDISPINFO)pNMHDR;            
            SendMessage(pNMHDR->idFrom, TTM_SETMAXTIPWIDTH, 300);             
            TipText->lpszText = szLongMessage;
      break;

But when I gave one of the tips a long line it still threw me out of the program when I tried to run it.
Louise
0

Featured Post

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.

Question has a verified solution.

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

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 …
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…

782 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