May 10, 2024, 09:36:53 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Listview and keypress

Started by Bruce Peaslee, December 03, 2007, 11:07:53 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Bruce Peaslee

December 03, 2007, 11:07:53 AM Last Edit: December 03, 2007, 11:09:29 AM by peaslee
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.
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

sapero

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.

Bruce Peaslee

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.
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles