When the user clicks on an iten in my list view, I detect and act on it with:
Case @IDCONTROL
Select @CONTROLID
Case AD_CMD_CLOSE
If @NOTIFYCODE = @BN_CLICKED
CloseDialog dlgAgenda,@IDOK
End If
Case AD_LVW_AGENDA
If @NOTIFYCODE = @NMCLICK
nLineNo = *<NMLISTVIEW>@LPARAM.iItem
If (nLineNo = -1) Then Return
ControlCmd dlgAgenda, AD_LVW_AGENDA, @LVGETTEXT, nLineNo, 2, sItemNo
SetControls_dlgAgenda(sItemNo)
End If
End Select
However, if the arrow keys are pressed, I am unable to detect it. I can't find a notify code value that reports a different line has been selected by key press.
A keypress you can detect inside @LVNKEYDOWN notification, where @LPARAM points to NMLVKEYDOWN structure.
More accurate would be to detect @LVNITEMCHANGED (@LPARAM=NMLISTVIEW) where
.iItem = item index, or -1 if all items changed
.uNewState can have LVIS_SELECTED bit set.
Works like a charm. Here is the modified code for others:
Case AD_LVW_AGENDA
If @NOTIFYCODE = @LVNITEMCHANGED
nLineNo = *<NMLISTVIEW>@LPARAM.iItem
If (nLineNo = -1) Then Return
ControlCmd dlgAgenda, AD_LVW_AGENDA, @LVGETTEXT, nLineNo, 2, sItemNo
SetControls_dlgAgenda(sItemNo)
End If
Thanks.