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
Thanks
Louise
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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,"Cl ick to Add new addresses");
break;
case IDC_ADDRESSDELETE:
strcpy(TipText->szText,"De letes the highlighted names");
break;
case IDC_BSTOP:
strcpy(TipText->szText, "Click to exit the screen");
default:
lpttd = (LPNMTTDISPINFO)lpnmhdr;
SendMessage(lpnmhdr->hwndF rom, TTM_SETMAXTIPWIDTH, 0, 300);
lpttd->lpszText = szLongMessage;
break;
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,"Cl
break;
case IDC_ADDRESSDELETE:
strcpy(TipText->szText,"De
break;
case IDC_BSTOP:
strcpy(TipText->szText, "Click to exit the screen");
default:
lpttd = (LPNMTTDISPINFO)lpnmhdr;
SendMessage(lpnmhdr->hwndF
lpttd->lpszText = szLongMessage;
break;
ASKER
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
default:
TipText = (LPNMTTDISPINFO)pNMHDR;
SendMessage(pNMHDR->idFrom
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
ASKER
UINT nID = pNMHDR->idFrom;
if ( TipText->uFlags & TTF_IDISHWND )
{
nID = ::GetDlgCtrlID((HWND)nID);
switch( nID )
{
case IDC_BADDNAME:
strcpy(TipText->szText,"Cl
break;
case IDC_ADDRESSDELETE:
strcpy(TipText->szText,"De
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