#include once "window9.bi"

Sub SetSelectListViewItem(ByVal gadget As long, ByVal Item As Long) Export
	Dim as LVITEM LV
	Dim As Integer mask
	If Item = -1 Then
		mask = LVIS_SELECTED
	Else
		mask = LVIS_SELECTED Or LVIS_FOCUSED
	EndIf
	LV.state = mask
	LV.statemask = mask
	If GetClassName_(GadgetID(gadget)) = "ExplorerGadget" Then
		SendMessage(GetProp(GadgetID(gadget),"EXPLORERGADGETLISTVIEWWINDOW"), LVM_SETITEMSTATE, CInt(item), Cast(lparam,@LV))
	else
		SendMessage(GadgetID(gadget), LVM_SETITEMSTATE, CInt(item), Cast(lparam,@LV))
	EndIf
End Sub
