Table 3-3 describes the messages and member functions supported by list view controls. The MFC class that supports these controls is the CListCtrl class. To use a list view control in your application, you must link with the COMCTL32.LIB library. If you write your application in C, you must include the COMMCTRL.H header file; if you write the application in MFC, you need to include the AFXCMN.H file in your STDAFX.H file (if you are using STDAFX.H).
Message | Member Function | Description |
LVM_ARRANGE | Arrange | Arranges the items in large icon view based on the flags set. |
LVM_CREATE- DRAGIMAGE | Create- DragImage | Creates a drag image for the specified item. |
LVM_DELETEALLITEMS | DeleteAllItems | Removes all items from a list view window. |
LVM_DELETECOLUMN | DeleteColumn | Removes a column from a list view window. |
LVM_DELETEITEM | DeleteItem | Removes a single item from a list view window. |
LVM_EDITLABEL | EditLabel | Begins in-place editing of an item's text label. This message selects and sets the focus to the item. When the user completes or cancels the editing, the edit window is destroyed and the handle becomes invalid. You can safely subclass the edit window, but do not destroy it. To cancel editing, send a WM_CANCELMODE message to the list view control. |
LVM_ENSUREVISIBLE | EnsureVisible | Ensures that an item is entirely or partially visible by scrolling the list view window if necessary. |
LVM_FINDITEM | FindItem | Searches for an item in a list view control. |
LVM_GETBKCOLOR | GetBkColor | Retrieves the background color of the list view window. |
Table 3-3. List view control messages and member functions. (continued)
Message | Member Function | Description |
LVM_GETCALLBACKMASK | GetCallbackMask | Retrieves the callback mask for a list view window. |
LVM_GETCOLUMN | GetColumn | Retrieves the attributes of a column in a list view control. The mask member of the LV_COLUMN structure passed in specifies which attributes to get. If the LVCF_TEXT flag is specified, the pszText member must contain the address of the buffer that receives the item's text, and the cchTextMax member must specify the size of the buffer. |
LVM_GETCOLUMNWIDTH | GetColumnWidth | Retrieves the width of a column in list view or details view. |
LVM_GETCOUNTPERPAGE | GetCountPerPage | Calculates the number of items that can fit vertically in the visible area in list view or details view. |
LVM_GETEDITCONTROL | GetEditControl | Retrieves the handle of the edit window used to edit an item's text label in place. The item being edited currently has the focus. When the user completes or cancels the editing, the edit window is destroyed and the handle becomes invalid. You can safely subclass the edit window, but do not destroy it. To cancel editing, send a WM_CANCELMODE message to the list view control. |
LVM_GETIMAGELIST | GetImageList | Retrieves the handle of an image list used for drawing items. |
LVM_GETITEM | GetItem | Retrieves the attributes of an item. |
LVM_GETITEMCOUNT | GetItemCount | Retrieves the number of items in a list view control. |
LVM_GETITEMPOSITION | GetItemPosition | Retrieves the position of an item in large icon view or small icon view. |
LVM_GETITEMRECT | GetItemRect | Retrieves the bounding rectangle for an item in the current view. |
(continued)
Message | Member Function | Description |
LVM_GETITEMSTATE | GetItemState | Retrieves the state of an item. |
LVM_GETITEMTEXT | GetItemText | Retrieves the text of an item or a subitem. |
LVM_GETNEXTITEM | GetNextItem | Searches for the next item, starting from a specified item. |
LVM_GETORIGIN | GetOrigin | Retrieves the list view origin point, which is needed for setting the item position. |
LVM_GETSTRINGWIDTH | GetStringWidth | Retrieves the minimum column width necessary to display the given string. The returned width takes the current font and column margins of the list view control (but not the width of a small icon) into account. |
LVM_GETTEXTBKCOLOR | GetTextBkColor | Retrieves the background text color in a list view window. |
LVM_GETTEXTCOLOR | GetTextColor | Retrieves the color of the text in a list view window. |
LVM_GETTOPINDEX | GetTopIndex | Retrieves the index of the first visible item in a list view window. |
LVM_GETVIEWRECT | GetViewRect | Retrieves the bounding rectangle of all items in large icon view. |
LVM_HITTEST | HitTest | Determines which item is at a specified position in a list view window. |
LVM_INSERTCOLUMN | InsertColumn | Inserts a new column in a list view window. |
LVM_INSERTITEM | InsertItem | Inserts a new item in a list view window. |
LVM_REDRAWITEMS | RedrawItems | Forces a redraw of a range of items in a list view control. The specified items are not repainted until the control receives a WM_PAINT message. To repaint immediately, call the UpdateWindow function after using this message. |
LVM_SCROLL | Scroll | Scrolls the contents of a list view window. In details view, the dx parameter must be 0, and the dy parameter is the number of lines to scroll. |
(continued)
Message | Member Function | Description |
LVM_SETBKCOLOR | SetBkColor | Sets the background color of a list view window. |
LVM_SETCALLBACKMASK | SetCallbackMask | Sets the callback mask for a list view window. |
LVM_SETCOLUMN | SetColumn | Sets the attributes of a column in a list view control. |
LVM_SETCOLUMNWIDTH | SetColumnWidth | Sets the width of a column in details view or list view. |
LVM_SETIMAGELIST | SetImageList | Sets the image list used for drawing items in a list view control. |
LVM_SETITEM | SetItem | Sets an item's attributes. |
LVM_SETITEMCOUNT | SetItemCount | Sets the item count of a list view control. |
LVM_SETITEMPOSITION | SetItemPosition | Sets the position of an item in large icon view or small icon view relative to the list view rectangle. |
LVM_SETITEMSTATE | SetItemState | Sets the state of an item. |
LVM_SETITEMTEXT | SetItemText | Sets the text of an item or a subitem. |
LVM_SETTEXTBKCOLOR | SetTextBkColor | Sets the background text color in a list view window. |
LVM_SETTEXTCOLOR | SetTextColor | Sets the text color in a list view window. |
LVM_SORTITEMS | SortItems | Sorts items in a list view control, using an application-defined comparison function. |
LVM_UPDATE | Update | Updates an item. If the list view control has the LVS_AUTOARRANGE style, the list view items will be automatically arranged in the window. |