Visual C++ and MFC Fundamentals Chapter 21: Tree and List Controls
Icons: The control displays a list of items using icons with a 32x32 pixels size of icons.
This is the preferred view when the main idea consists of giving an overview of the items
Small Icons: Like the other next two views, it uses 16x16 pixel icons to display a
simplified list of the items. Once more, no detail is provided about the items of this list.
The list is organized in disparate columns with some on top of others. If the list is
supposed to be sorted, the alphabetical arrangement is organized from left to right.
List: This list, using small icons, is also organized in columns; this time, the columns are
arranged so that the first column gets filled before starting the second. If the list is sorted,
the sorting is arranged in a top-down manner.
Report: This view displays arranged columns of items and provides as many details as
the list developer had arranged it.
21.3.2..List Control Creation..........................................................................
A list control is implemented in the MFC library by the CListCtrl class. At design time,
to create a list control, on the Controls toolbox, click the List Control button and
click the desired area on a dialog box or a form. Normally, you should expand its
dimensions beyond the default assigned because a list control is usually used to display
its items on a wide rectangle.
To programmatically create a list control, declare a variable or a pointer to CListCtrl. To
initialiaze the control, call its Create() method. Here is an example:
BOOL CPictureDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CListCtrl *lstCtrl = new CListCtrl;
lstCtrl->Create(WS_CHILD | WS_VISIBLE,
CRect(10, 10, 320, 280), this, 0x285);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
As mentioned already, a list control can display its items in one of four views. To specify
the desired view at design time, on the Properties window, select a value from the View
combo box. The default value is Icon. The possible values are: