Make sure though that you catch all selection-related events and set SelectedItem accordingly. They are:
OnWindowIdEvent_LstViewClicked();
OnWindowIdEvent_LstViewDblClicked();
OnWindowIdEvent_LstViewRightClicked();
A value of -1 means that no item is currently selected. That means, for example, there is only one item in the list-view control, and you click below that item.
Also, make sure to set SelectedItem back to -1 when the window is destroyed.
There's another way to get it working without dealing with a variable in those events
JScript code:var LVM_FIRST = 0x1000;
var LVM_GETNEXTITEM = LVM_FIRST + 12;
var LVNI_SELECTED = 0x2;
var SelectedItem = PlusWnd.SendControlMessage('vLstTest', LVM_GETNEXTITEM, -1, LVNI_SELECTED);