Click here to Skip to main content
Licence 
First Posted 20 Feb 2001
Views 102,618
Bookmarked 32 times

List Box with ToolTips

By | 20 Feb 2001 | Article
A listbox that displays tooltips for items
  • Download source files - 5 Kb
  • Download demo project - 14 Kb
  • Sample Image - TTListBoxDemo.gif

    Introduction

    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:
       m_listbox.SetTextRetrieverFcn(TextRetriever);

      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.

    License

    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

    Member



    Sign Up to vote   Poor Excellent
    Add a reason or comment to your vote: x
    Votes of 3 or less require a comment

    Comments and Discussions

     
    You must Sign In to use this message board. (secure sign-in)
     
    Search this forum  
     FAQ
        Noise  Layout  Per page   
      Refresh
    Generalcan't use ItemData in function TextRetriever Pinmemberyy123422:13 2 Jul '08  
    GeneralRe: can't use ItemData in function TextRetriever Pinmemberyy123423:30 2 Jul '08  
    QuestionNice class - Improvments [modified] PinmemberAli Rafiee12:01 20 Apr '06  
    GeneralSelect item Pinmemberalexan081:41 24 Dec '04  
    GeneralItem click Pinmemberdudic5:04 13 Mar '03  
    GeneralList Box Background color PinsussAshwani20:11 11 Sep '02  
    GeneralMulti ListBoxes with different tooltips PinmemberPepe6:06 27 Jul '01  
    GeneralDisplay speed/delay PinmemberMark Ovens9:37 26 Jun '01  
    GeneralSolved :) Re: Display speed/delay PinmemberMark Ovens8:28 27 Jun '01  
    Generaltooltip window position is not right Pinmemberlaxman8:14 21 Feb '01  
    GeneralRe: tooltip window position is not right PinmemberSalman Khilji2:58 23 Feb '01  

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    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 | Mobile
    Web02 | 2.5.120517.1 | Last Updated 21 Feb 2001
    Article Copyright 2001 by Salman A Khilji
    Everything else Copyright © CodeProject, 1999-2012
    Terms of Use
    Layout: fixed | fluid