Link to home
Start Free TrialLog in
Avatar of c_louise
c_louise

asked on

multi line tool tips

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
ASKER CERTIFIED SOLUTION
Avatar of derekcmartin
derekcmartin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of c_louise
c_louise

ASKER

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
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;

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