Download source files - 6 Kb
Download demo project - 19 Kb
I have been ever perplexed by the question which's tool-tip associated with Combo-box,
On the internet I have searched lots of samples about this but these samples look like so complex, some samples that have wrapped the Combo-box using separated controls 'CListbox', 'CEdit', 'CButton', so that corresponding to generate many extra class for the Combo-box that lots of work to maintain the Combo-box. A couple of samples has using hooks for window subclassing that all messages go to new WindowProc(window procedure) before going to the combobox, ummm..., that's very useful. but they still don't be enough simply, thus base upon these samples I have wrapped a enhanced class CTTCombobox, According to expectation there use the new WindowProc to hold up the List-box's messages
and to do too-tip things. BTW, for the enhanced class CTTCombobox, the source files only contain 'TTCombobox.h' and 'TTCombobox.cpp',
that's very easy to embed into your VC++ project.
The class CTTComboBox isn't wrapped using separated controls 'CListbox', 'CEdit', 'CButton'.
1. The class CTTComboBox is derive from MFC class CCombobox, you can immediately use the class CTTComboBox as well as make new class derive from it.
2. Default, the too-tip is allowed for the combobox(instance with the class CTTComboBox), to enable/disable the too-tip, you need to perform the SetToolTip function before creating or subclassing combobox, details see attached demo project.
3. Using SetToolTipDelay function to set up the appropriate delayed time for show the tool-tip window.
As mention above, default the tool-tip is allowed mean m_isEnableTool is TRUE, see codes as follows:
We have perform CreateTooltipWnd function that will createa tool-tip window
(note: all combobox with same class CTTComboBox has share a tool-tip window), then we have install hook for subclassing the list-box and edit-box portion of the combobox, see InstallHookForListboxAndEditbox function:
Specially, The combobox with owner DropList or DropDown style has a litte trouble, when release the mouse capture, the list-box became invisible.
thus I have hold the WM_CAPTURECHANGED and ignore the message...
you are allowed to use it for free and further modify it.