Originally posted by Sam Hobbs
The third Parameter of SetItemState is a mask value and LVIS_SELECTED is not a mask value.
The mask parameter for SetItemState is a stateMask and LVIS_SELECTED can be used for this parameter to tell SetItemState that you want only the items selection bits to be changed, so you can use LVIS_SELECTED as a mask value in this case.

Russ