Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This macro changes the state of an item in a list-view control. You can use this macro or send the LVM_SETITEMSTATE message explicitly.

Syntax

void WINAPI ListView_SetItemState( 
  HWND 
hwnd, 
  int 
i, 
  UINT 
state, 
  UINT 
mask 
);

Parameters

hwnd

Handle to the list-view control.

i

Index of the list-view item. If this parameter is 1, then the state change is applied to all items.

state

New state bits for the item. The maskparameter indicates the valid bits of the stateparameter. The macro ignores bits in the stateparameter if the corresponding bit is not set in the maskparameter.

The low-order byte contains a set of bit flags that indicate the item's state. This byte can be a combination of the following values.

Value Description

LVIS_CUT

The item is marked for a cut-and-paste operation.

LVIS_DROPHILITED

The item is highlighted as a drag-and-drop target.

LVIS_FOCUSED

The item has the focus, so it is surrounded by a standard focus rectangle. Although more than one item may be selected, only one item can have the focus.

LVIS_SELECTED

The item is selected. The appearance of a selected item depends on whether it has the focus and also on the system colors used for selection.

Bits 8 through 11 of the stateparameter specify the one-based index of an overlay image in the control's image lists. Both the full-sized icon image list and the small icon image list can have overlay images. The overlay image is superimposed over the item's icon image. If these bits are zero, the item has no overlay image. To isolate these bits, use the LVIS_OVERLAYMASK mask. To specify an overlay index, use the INDEXTOOVERLAYMASKmacro.

Bits 12 through 15 of the stateparameter specify the one-based index of an image in the control's state image list. The state image is displayed next to an item's icon to indicate an application-defined state. If these bits are zero, the item has no state image. To isolate these bits, use the LVIS_STATEIMAGEMASK mask. To specify a state image index, use the INDEXTOSTATEIMAGEMASKmacro.

mask

Bits of the stateparameter that you want to set or clear. You can use ListView_SetItemStateboth to set and to clear bits. To set an item's overlay image index, set the LVIS_OVERLAYMASK bits. To set an item's state image index, set the LVIS_STATEIMAGEMASK bits.

Return Value

None.

Remarks

An item's state value includes a set of bit flags that indicate the item's state. The state value can also include image list indexes that indicate the item's state image and overlay image.

The maskparameter specifies the state bits you want to modify, and the stateparameter specifies the new value for those bits. To set a bit in the item's internal state, set it in both the maskand stateparameters. To clear a bit in the item's internal state, set it in the maskparameter and clear it in the stateparameter. To leave a bit unchanged in the item's internal state, clear it in the maskparameter.

Related message:  LVM_SETITEMSTATE

Requirements

Header commctrl.h
Windows Embedded CE Windows CE 1.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also