Will Sadkin was wondering why the wxListCtrl doesn't automatically show a tool tip on wxMSW when the items are partially obscured. The wxTreeCtrl does it and the list control in other apps does it too...

So Will and friends did a bit of research and figured out how to do it. " requires a recent version of the comctl32.dll (version 5.80+), such as distributed with IE5, but it works."

The Code

Here's a snippet showing how to do it:

# Turn on labeltips in list control
from win32api import SendMessage
import commctrl # from win32 extensions for constants

# All of the extended label styles are missing from the 
# current version (1.1) of, but this is the value 
# needed:

style = SendMessage(listCtrl.GetHandle(), 
                    commctrl.LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0)
style = style | LVS_EX_LABELTIP
            commctrl.LVM_SETEXTENDEDLISTVIEWSTYLE, 0, style)

Other Options

There is also a LVS_EX_INFOTIP style that can be used with 4.71+ of comctl32.dll, but requires responding to a notification message to set the text to be used for the tool tip. If somebody wants to make a patch to the C++ code for wxListCtrl that implements this I'm sure it will be accepted.

wxListCtrl ToolTips (last edited 2008-03-11 10:50:27 by localhost)

NOTE: To edit pages in this wiki you must be a member of the TrustedEditorsGroup.