Click here to Skip to main content
13,511,336 members
Click here to Skip to main content
Add your own
alternative version


35 bookmarked
Posted 20 Feb 2001

List Box with ToolTips

, 20 Feb 2001
Rate this:
Please Sign up or sign in to vote.
A listbox that displays tooltips for items
<!-- Download Links -->
  • Download source files - 5 Kb
  • Download demo project - 14 Kb
  • <!-- Article image -->

    Sample Image - TTListBoxDemo.gif

    <!-- Main HTML starts here -->


    This tooltip enabled class lets the user display tooltip text for individual items. This class uses the tooltip class that is written by Dhandapani Ammasai.

    A multiline tooltip for an individual item is automatically displayed towards the right of the control and the text is updated as the mouse is moved over the individual items in the list box.

    Follow these steps to add a CTTListBox to a dialog:

    • Add TTListBox.cpp and TTListBox.h to your project.
    • Add tooltip2.cpp and tooltip2.h to your project.
    • Add include "TTListBox.h" to the header file of your dialog class.
    • Add a list box control to your dialog.
    • Use ClassWizard to add a member variable of type CTTListBox for the list box you just added. If CTTListBox is not in the Variable Type list, choose CListBox, and manually change the type to CTTListBox later.
    • In your dialog class, define a static member function which retrieves the the text for individual items. This function must be declared as:
      static CString TextRetriever(int nIndex);

      where nIndex is the index of the list box item that currently is under the mouse cursor and wants to have the text retrieved.

    • Implement the text retriever function the way you want it.
    • In your dialog's class OnInitDialog function include a statment like:

      where TextRetriever is the name of your text retriever function that you declared earlier.

    I have also implemented the same functionality for a tree control. You can e-mail me if you wish to look at how I implemented it for a tree control.


    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    A list of licenses authors might use can be found here


    About the Author

    Salman A Khilji
    United States United States
    No Biography provided

    You may also be interested in...

    Comments and Discussions

    Generalcan't use ItemData in function TextRetriever Pin
    yy12342-Jul-08 22:13
    memberyy12342-Jul-08 22:13 
    GeneralRe: can't use ItemData in function TextRetriever Pin
    yy12342-Jul-08 23:30
    memberyy12342-Jul-08 23:30 
    QuestionNice class - Improvments [modified] Pin
    Ali Rafiee20-Apr-06 12:01
    memberAli Rafiee20-Apr-06 12:01 
    GeneralSelect item Pin
    alexan0824-Dec-04 1:41
    memberalexan0824-Dec-04 1:41 
    GeneralItem click Pin
    dudic13-Mar-03 5:04
    memberdudic13-Mar-03 5:04 
    GeneralList Box Background color Pin
    Ashwani11-Sep-02 20:11
    sussAshwani11-Sep-02 20:11 
    GeneralMulti ListBoxes with different tooltips Pin
    Pepe27-Jul-01 6:06
    memberPepe27-Jul-01 6:06 
    GeneralDisplay speed/delay Pin
    Mark Ovens26-Jun-01 9:37
    memberMark Ovens26-Jun-01 9:37 
    GeneralSolved :) Re: Display speed/delay Pin
    Mark Ovens27-Jun-01 8:28
    memberMark Ovens27-Jun-01 8:28 
    Generaltooltip window position is not right Pin
    laxman21-Feb-01 8:14
    memberlaxman21-Feb-01 8:14 
    GeneralRe: tooltip window position is not right Pin
    Salman Khilji23-Feb-01 2:58
    memberSalman Khilji23-Feb-01 2:58 

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

    Permalink | Advertise | Privacy | Terms of Use | Mobile
    Web04 | 2.8.180417.1 | Last Updated 21 Feb 2001
    Article Copyright 2001 by Salman A Khilji
    Everything else Copyright © CodeProject, 1999-2018
    Layout: fixed | fluid