CListBox
One: Entry Description
CObject←CCmdTarget←CWnd←CListBox
CListBox class provides Windows list box functions. List of items, such as the user can see and select the file name list box is displayed. In the single-selection list box, the user can select only one item. In the multiple-selection list box, you can select a number of items. When the user selects an item, which is highlighted and a list box to the parent window sends a notification message.
Or you can create a list box in your code directly from the dialog template. When directly create, construct CListBox the object , and then call the Create member function to create a Windows list box control and attach it to the CListBox objects . To use the list box in the dialog template, you can declare a class in the dialog box CListbox variables, and then in the dialog class DoDataExchange use DDX_Control connection member variables of this control ( when adding a control variable to the dialog class, the ClassWizard automatically for you to achieve).
The constructor can be from CListBox a single-step process derived class. Write a constructor for the derived class and calls from the Create . If you want to deal with a list box to be sent by his father (usually from CDialog derived class) in the Windows notification message, add a message map entry and message processing member function to the parent class for each message.
Each message map entry has the following form:
ON_Notification( id,memberFxn )
id specifies the child window sends a notification of the list box control , memberFxn is where the parent member function names written notification process .
Parent function prototype is as follows:
afx_msg void memberFxn( );
The following is a possible message mapping entry list and description thereof may be sent to the case where the father:
ON_LBN_DBLCLK user double-clicks a string in the list box. Only LBS_NOTIFY style list box will send notification messages.
ON_LBN_ERRSPACE list box can not be re-allocate enough memory to satisfy the request.
ON_LBN_KILLFOCUS list box is losing the input focus.
ON_LBN_SELCANCEL current list box selection is canceled. This message only if the list box is LBS_NOTIFY send only style.
ON_LBN_SELCHANGE list box may change. If the selection is CListBox :: SetCurSel member functions, notification is not sent. This notice applies only to LBS_NOTIFY style list box. Whenever the user presses the arrow keys, even if the selection is not changed, LBN_SELCHANGE notification messages are sent to the multiple selection list box.
ON_LBN_SETFOCUS list box is receiving the input focus.
ON_WM_CHARTOITEM a free draw from the list of accepted string WM_CHAR message.
ON_WM_VKEYTOITEM LBS_WANTKEYBOARDINPUT style list box to accept WM_KEYDOWN messages.
If a structure in the dialog box CListBox object when the user closes the dialog box (through dialogue resource) CListBox object is automatically destroy.
If a structure in the window CListBox object, you may need to destroy CListBox object. If you created on the stack CListBox object, it will automatically destroy. If a new function is created on the heap CListBox the object, the object must call this delete to destroy it when the user closes the parent window.
If CListBox allocation of memory objects, may cover CListBox destructor program releases memory allocation.
#include <afxwin.h>
See: CWnd, CButton, CComboBox, CEdit, CScrollBar, CStatic
II: Class Members
CListBox members of the class
Constructor CListBox constructed a CListBox objects
Initialization Create Create a Windows list box and attaches to CListBox objects
InitStorage list box and string of pre-allocated memory block
General Procedure:
GetCount number of the returned string in the list box
GetHorizontalExtent return horizontal width list box, expressed in pixels
SetHorizontalExtent list boxes horizontal width, expressed in pixels
GetTopIndex returns the index of the first visible string in the list box
SetTopIndex set list box first visible string of zero-based index
GetItemData returns a list box related 32 -bit value
GetItemDataPtr returns a pointer to a pointer to the list box
SetItemData list boxes associated 32 bit value
SetItemDataPtr provided a pointer pointing the list box
GetItemRect returns the corresponding list of rectangles box item currently displayed
ItemFromPoint return index and a point nearest the list box item
SetItemHeight set the height of the list box item
GetItemHeight determine the height of the list box items
GetSel return an item selection list box
GetText copy of a list box item into the buffer
GetTextLen returns a list box bytes
SetColumnWidth disposed plurality listbox column width
SetTabStops list boxes tab key stop position
GetLocale get a list box location identifier
SetLocale set list box location identifier
Radio operation GetCurSel returns the list box of the currently selected string zero-based index
SetCurSel select a list box string
Multi-select operation SetSel in a multiple-selection list box, select or deselect a listbox item
GetCaretIndex determine the focus rectangle in a multiple-selection list box item index
SetCaretIndex provided to focus rectangle multiple selection list box specified index entry
GetSelCount Returns a string multiple-selection list box, the currently selected number
GetSelItems index returns a list of the currently selected string of box
SelItemRange choose / not choose some string multiple selection list box
SetAnchorIndex set up multiple-selection list box to select an anchor to begin expansion
GetAnchorIndex get a list box item index of the current anchor zero-based
String manipulation:
AddString add a string to the list box
DeleteString remove a string from the list box
InsertString insert a string at the specified location in the list box
ResetContent clear the list box all entries
Dir from the current directory to add the file name to the list box
FindString Find a string in the list box
FindStringExact find the first string and a list box that matches the specified string
SelectString Find and select the radio list box of a string
Function may cover DrawItem when changing from a visible part of the drawing list box, the frame is called
MeasureItem when the self-draw list box created by the framework calls to determine the list box dimension
CompareItem is called the framework to determine the location of a series of new items in the list box
DeleteItem When the user from the self-draw list box to delete an item, to be called framework
VKeyToItem coverage to provide LBS_WANTKEYBOARDINPUT custom style list box to set the desired WM_KEYDOWN
CharToItem cover to provide free draw strings from the list box custom WM_CHAR
Three: Constructor
CListBox::CListBox
CListBox( );
Description:
Construct a two-step CListBox object. First, call the constructor CListBox , then call the Create , initialize the Windows list box and attaches it to the CListBox .
See: CListBox the Create ::
Reproduced in: https: //my.oschina.net/u/204616/blog/545503