Share via


Creating Multiline ToolTips (Windows Embedded CE 6.0)

1/6/2010

Multiline ToolTip support allows you to display more than one line of ToolTip text. This option is useful if your message is too long for a user to read easily as a single line of text.

You create a multiline ToolTip when you respond to the TTN_GETDISPINFO notification. To force the ToolTip control to use multiple lines, send a TTM_SETMAXTIPWIDTH message that specifies the width of the display rectangle. Text that exceeds this width wraps to the next line instead of widening the display region. The rectangle height increases as needed to accommodate the additional lines. The ToolTip control wraps the lines automatically. You can also use a carriage return/line feed combination (\r\n) to force line breaks at particular locations.

The text buffer in the NMTTDISPINFO structure accommodates only 80 characters. If you need a longer string, set the lpszText member of the NMTTDISPINFO structure to point to a buffer that contains the text that you want to use.

The following code example shows a simple TTN_GETDISPINFO notification handler. The code example creates a multiline ToolTip by setting the display rectangle to 300 pixels and by setting the lpszText member of the NMTTDISPINFO structure to point to a buffer with the text to use.

char szLongMessage[] =
"This message is a long message for the ToolTip that wraps automatically "
"when the length of the message 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;


// Include other notification handlers, as needed.
}

See Also

Concepts

Using ToolTips
Creating a ToolTip Control