List Control)
The List View control is a very common control. When you need to display data in the form of reports, the list control is usually the best choice. Many dedicated data report controls, it is also derived from it. Similar to the Tree View, the list control can be composed of multiple sub-projects and displays information in four ways: Large icons, small icons, lists, and reports, as shown in 1.
Figure 1 four display modes in the List View
The list view contains a project list. Each project consists of icons, project names, and multiple sub-items. Each sub-item must contain the same number of projects, each subitem with the same attributes is displayed in the same column. The List View control has two important data structures: lvcolumn and lvitem. Lvcolumn is used to define the structure of the "column" in the report mode; lvitem is used to define the structure of the "item. The definitions and descriptions of these two structures are as follows:
Typedef Struct _ Lvcolumn {uint mask; // Which members are valid in this structure? Int FMT; // Column alignment Int CX;// Initial column width Lptstr psztext; // Column Title Int Cchtextmax; // Size of the buffer to which psztext points Int Isubitem; // Index value of the subitem associated with the column, starting from 0 Int Iimage; // Index value of the specified image in the image list associated with the column Int Iorder;// Column number. 0 indicates the leftmost column. } Lvcolumn, far * Lplvcolumn; typedef Struct _ Lvitem {uint mask; // Description of which members are valid in the lvitem Structure Int IItem; // The index value of the project (which can be regarded as the row number) starts from 0. Int Isubitem; // The index value of the subitem (which can be regarded as the column number) starts from 0. Uint state; // Subitem status Uint statemask; // Valid shielding bit status Lptstr psztext; // Name of the primary or subitem Int Cchtextmax; // Buffer size pointed to by psztext Int Iimage; // Index value of the specified image in the associated image list Lparam; // Program32-bit parameter defined Int Iindent; // The unit that indicates the indent of the image position. } Lvitem, far * lplvitem;
Common attributes of a list item are as follows:
View specifies how the List View control is initially displayed after the program runs. It can be set to icon (large icon), smallicon (small icon), list (list), or report (report );
Single Selection indicates that only one item can be selected at a time;
Auto arrange enables projects to be automatically sorted in the icon and small icon display modes;
Edit labels: You can edit the volume label of a project;
No column header indicates canceling the title of all columns of the control.
Mask// Indicate the features set of flags that specify which members of this structure contain data to be set or which members are being requested. this can be one or more of the following flags:
Lvif_text |
ThePsztextMember is valid or must be filled in. |
Lvif_image |
TheIimageMember is valid or must be filled in. |
Lvif_indent |
TheIindentMember is valid or must be filled in. |
Lvif_norecompute |
The control will not generate lvn_getdispinfo to retrieve text information if it has es a lvm_getitem message. Instead,PsztextMember will contain lpstr_textcallback. |
Lvif_param |
TheLparamMember is valid or must be filled in. |
Lvif_state |
TheStateMember is valid or must be filled in. |
Lvif_di_setitem |
The operating system shocould store the requested list item information and not ask for it again. This flag is used only with the lvn_getdispinfo notification message. |