Visual C++ and MFC Fundamentals Chapter 21: Tree and List Controls
21.4.1..Overview...............................................................................................
The list control we have used so far is a regular control added to a dialog box or a form.
The Document/View Architecture of the MFC allows you to create a broader frame-
based application whose view is an implementation of the list control. This is called the
List View.
The list view application is a program based on the CListView class. There are various
ways you can create such an application. You can work from scratch. In this case, you
would derive a class from CListView. Alternatively, you can create a form-based
application, then add a list control that uses part or its whole client area. Fortunately,
Visual C++ provides a good starting point to create a list view application. This is done
by using the MFC Application wizard.
To create a list view, you can start a new MFC Application and, on the Based Class,
select CListView. If you open the header file of the view class, you would notice that it is
based on CListView.
Practical Learning: Creating a List View-Based Application
- Start a new MFC Application and name it Countries1
- Set the Application Type to Single Document
- Change the Main Frame Caption to Countries Listing
- Remove the Printing And Print Preview option
- Set the Base Class to CListView
- Click Finish
21.4.2..List View Implementation.................................................................
The list view is simply a technique of implementing a list control on a frame-based
application using the Document/View architecture. All of the functionality emanates
from the CListCtrl class. Therefore, in order to do anything, you should obtain a
reference to the underlying CListCtrl already available by deriving a class from
CListView.