List Views

A list view is a common control that displays a collection of items, such as files or folders. Each item has an icon and a label. A user can choose whether to have the items displayed as large icons, small icons, a list, or a detailed list. You can design list views so that a user can drag an item to a new location within the list view, or sort the collection by tapping a column header. The following screen shot illustrates an image list in list view.

    

Image list in list view

You create a list view by specifying WC_LISTVIEW in the lpClassName parameter to the CreateWindowEx function. This class is registered when the common control DLL is loaded. You can use the InitCommonControls function to ensure that this DLL is loaded.

To register the list view class using the InitCommonControlsEx function, specify the ICC_ LISTVIEW_CLASSES flag as the dwICC member of the INITCOMMONCONTROLSEX structure you pass in the lpInitCtrls parameter.

Note You can speed up the creation of large list views by disabling the painting of the list view before adding the items. You do this by sending a WM_SETREDRAW message, with the redraw flag in wParam set to FALSE. When you are finished adding items, re-enable painting by sending a WM_SETREDRAW message, with the redraw flag wParam set to TRUE. Before inserting items, it is also a good idea to send the LVM_SETITEMCOUNT message with the cItems parameter, wParam, set to the number of items in question. When you do this, the list view will allocate the memory it needs all at once, instead of having to reallocate more memory incrementally as the internal data structures grow.

You can change the view type after a list view control is created. To retrieve and change the window style, use the GetWindowLong and SetWindowLong functions. To determine the window styles that correspond to the current view, use the LVS_TYPEMASK value.

Note Windows CE does not support hot tracking, hover selection, background images, or list view ToolTips.