Microsoft Foundation Classes (mfc.hlp) (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
class CListBox
CWnd                                        Up Contents Index Back
──Microsoft Foundation Classes──────────────────────────────────────────────
 
  Description
 
  The CListBox class provides the functionality of a Windows list box. A
  list box displays a list of items, such as filenames, that the user can
  view and select.
 
  In a single-selection list box, the user can only select one item. In a
  multiple-selection list box, a range of items can be selected. When the
  user selects an item, it is highlighted and the list box sends a
  notification message to the parent window.
 
  The list box itself automatically displays horizontal or vertical scroll
  bars if the list within the box is too large for the list-box window.
 
  You create a list-box control in two steps. First, call the constructor
  CListBox to construct the CListBox object, then call the Create member
  function to create the Windows list-box control and attach it to the
  CListBox object.
 
  Construction can be a one-step process in a class derived from CListBox.
  Write a constructor for the derived class and call Create from within
  the constructor.
 
  If you want to handle the Windows notification messages sent by a
  CListBox object to its parent (usually a class derived from CDialog or
  CModalDialog), add the appropriate message-map entries and
  message-handler member functions to the parent class to handle the
  messages you want to process. Potential message-map entries are:
 
  ON_COMMAND
  ON_LBN_DBLCLK
  ON_LBN_ERRSPACE
  ON_LBN_KILLFOCUS
  ON_LBN_SELCHANGE
  ON_LBN_SETFOCUS
 
  If you create a CListBox object within a dialog box (through a dialog
  resource), the CListBox is automatically destroyed when the user closes
  the dialog box.
 
  If you create a CListBox object within a window, you may also need to
  destroy it. If you create the CListBox object on the stack, it is
  destroyed automatically. If you create the CListBox object on the heap
  by using the new function, you must call delete on the object to destroy
  it when the user terminates the Windows list box.
 
  If you allocate any memory in the CListBox object, override the CListBox
  destructor to dispose of the allocations.
 
  See Also
 
  CWnd, CButton, CComboBox, CEdit, CScrollBar, CStatic,
  CModalDialog, CDialog
 
  Public Members
 
  Construction/Destruction
 
  CListBox   Constructs a CListBox object.
 
  Initialization
 
  Create   Creates the Windows list box and attaches it to the CListBox
             object.
 
  General Operations
 
  GetCount              Returns the number of strings in a list box.
 
  GetHorizontalExtent   Returns the width in pixels that a list box can
                          be scrolled horizontally.
 
  SetHorizontalExtent   Sets the width in pixels that a list box can be
                          scrolled horizontally.
 
  GetTopIndex           Returns the index of the first visible string in
                          a list box.
 
  SetTopIndex           Sets the zero-based index of the first visible
                          string in a list box.
 
  GetItemData           Returns the 32-bit value associated with the
                          list-box item.
 
  SetItemData           Sets the 32-bit value associated with the
                          list-box item.
 
  GetItemRect           Returns the bounding rectangle of the list-box
                          item as it is currently displayed.
 
  GetSel                Returns the selection state of a list-box item.
 
  GetText               Copies a list-box item into a buffer.
 
  GetTextLen            Returns the length in bytes of a list-box item.
 
  SetColumnWidth        Sets the column width of a multicolumn list
                          box.
 
  SetTabStops           Sets the tab-stop positions in a list box.
 
  Single Selection Operations
 
  GetCurSel   Returns the zero-based index of the currently selected
                string in a list box.
 
  SetCurSel   Selects a list-box string.
 
  Multiple Selection Operations
 
  SetSel         Selects or deselects a list box item in a
                   multiple-selection list box.
 
  GetSelCount    Returns the number of strings currently selected in a
                   multiple-selection list box.
 
  GetSelItems    Returns the indices of the strings currently selected
                   in a list box.
 
  SelItemRange   Selects or deselects a range of strings in a
                   multiple-selection list box.
 
  String Operations
 
  AddString      Adds a string to a list box.
 
  DeleteString   Deletes a string from a list box.
 
  InsertString   Inserts a string at a specific location in a list box.
 
  ResetContent   Clears all the entries from a list box.
 
  Dir            Adds filenames from the current directory to a list
                   box.
 
  FindString     Searches for a string in a list box.
 
  SelectString   Searches for and selects a string in a single-selection
                   list box.
 
  Windows 3.1 Functions
 
  SetItemHeight     Sets the height of items in a list box.
 
  GetItemHeight     Determines the height of items in a list box.
 
  FindStringExact   Finds the first list box string that matches a
                      specified string.
 
  GetCaretIndex     Determines the index of the item that has the focus
                      rectangle in a multiple-selection list box.
 
  SetCaretIndex     Set the focus rectangle to the item at the specified
                      index in a multiple-selection list box.
 
 
                                     -♦-