IonicWind Software

IWBasic => GUI Central => Topic started by: Bruce Peaslee on December 03, 2007, 11:07:53 AM

Title: Listview and keypress
Post by: Bruce Peaslee on December 03, 2007, 11:07:53 AM
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.
Title: Re: Listview and keypress
Post by: sapero on December 03, 2007, 02:56:05 PM
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.
Title: Re: Listview and keypress
Post by: Bruce Peaslee on December 03, 2007, 03:11:13 PM
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.