• LVN_KEYDOWN - how to discard the keypress

    From R.Wieser@21:1/5 to All on Wed Dec 23 11:36:19 2020
    Hello all,

    I've got a listview in which I when the "up" or "down" arrow is pressed when
    on the top or bottom rows the contents of the listview are reloaded and I
    set the bottom / top row as focussed and selected.

    The problem is that the actual focussed and selected row becomes the second
    one / one before last. I take it that that happens because the listviews internal mechanics still see the "up" / "down" keypress and executes it -
    after I placed the "cursor" on the top / bottom row.

    My question therefore is:
    Can I, in the LVN_KEYDOWN event, either erase the keystroke or mark the it
    as already having been handled ?

    Regards,
    Rudy Wieser

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From JJ@21:1/5 to R.Wieser on Thu Dec 24 06:12:28 2020
    On Wed, 23 Dec 2020 11:36:19 +0100, R.Wieser wrote:
    Hello all,

    I've got a listview in which I when the "up" or "down" arrow is pressed when on the top or bottom rows the contents of the listview are reloaded and I set the bottom / top row as focussed and selected.

    The problem is that the actual focussed and selected row becomes the second one / one before last. I take it that that happens because the listviews internal mechanics still see the "up" / "down" keypress and executes it - after I placed the "cursor" on the top / bottom row.

    When LVN_KEYDOWN is posted, the UI control's code for updating the item selection is not yet executed at that point. The UI control is not yet at
    the point where it checks the keystroke to deteremine what task is assigned
    for that keystroke.

    Why use LVN_KEYDOWN instead of LVN_ITEMCHANGED?

    My question therefore is:
    Can I, in the LVN_KEYDOWN event, either erase the keystroke or mark the it
    as already having been handled ?

    Regards,
    Rudy Wieser

    No. Because WM_NOTIFY is just a notice of something which has already
    occured and processed.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From R.Wieser@21:1/5 to All on Thu Dec 24 08:54:55 2020
    JJ,

    Why use LVN_KEYDOWN instead of LVN_ITEMCHANGED?

    Because pressing the "up" key on the top row can't be executed (you would
    move outof the list) and thus doesn't change the item (same for "down" and bottom row) ?

    No. Because WM_NOTIFY is just a notice of something which has
    already occured and processed.

    :-) If the up / down keystroke is already processed than my focussing and selecting of the bottom / top row would be the happening later, meaning that
    my selection should not move afterwards. That it does seems to indicate
    that the processing happens later.

    And I can't believe I did not think of trying to use the LVN_KEYUP
    notification until now. The only problem is that that notification doesn't exist .... :-( :-)

    Regards,
    Rudy Wieser

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From JJ@21:1/5 to R.Wieser on Thu Dec 24 21:30:48 2020
    On Thu, 24 Dec 2020 08:54:55 +0100, R.Wieser wrote:

    And I can't believe I did not think of trying to use the LVN_KEYUP notification until now. The only problem is that that notification doesn't exist .... :-( :-)

    Regards,
    Rudy Wieser

    When LVN_KEYDOWN occurs and with matching key conditions, you could use
    posted application message(s) as your own e.g. "LVN_AFTER_UP_KEYDOWN". It
    might need to be reposted several times, depending on how many actual
    messages are normally posted between a LVN_KEYDOWN and LVN_ITEMCHANGED, in order to skip to the point where item selection is normally have changed.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)