Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleMake a multi-line tooltip
DescriptionThis example shows how to make a multi-line tooltip in Visual Basic 6. It uses the CreateWindowEx API function to make a window with the TTS_ALWAYSTIP style.
Keywordstooltip, multiline tooltip, multi-line tooltip
CategoriesControls, API
 
Thanks to Dipak Auddy.

To create the tooltip window, the program calls the CreateWindowEx API function, passing it the TTS_ALWAYSTIP style.

 
mnlgHwndTT = CreateWindowEx(0, TOOLTIPS_CLASS, _
    vbNullString, TTS_ALWAYSTIP, 0, 0, 0, 0, frm.hWnd, 0, _
    App.hInstance, ByVal 0)
 
To modify the tooltip window's properties, the program uses the SendMessageT API function to send it various messages. For example, the following code uses the TTM_SETMAXTIPWIDTH message to set the window's maximum width to lngWidth pixels.
 
    Call SendMessageT(mnlgHwndTT, TTM_SETMAXTIPWIDTH, 0, _
        lngWidth)
 
Similar code sets the tooltip's background and foreground colors, margin, delay time, the control to which the tooltip is attached, and text. See the code for the complete details.

Thanks to Roger Gilchrist for some additions:

  • HasToolTip method tells whether a control has a tooltip.
  • Silently ignores attempts to add a tooltip to windowless controls such as labels.
  • ToolTipHeader and ToolTipHeaderShow properties let you add a custom first line to each ToolTip and to turn it on/off per control.
  • Remove controls from the list when ToolTip is set to an empty string ("").
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated