Discussion:
LVN_KEYDOWN - how to discard the keypress
(too old to reply)
R.Wieser
2020-12-23 10:36:19 UTC
Permalink
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
JJ
2020-12-23 23:12:28 UTC
Permalink
This post might be inappropriate. Click to display it.
R.Wieser
2020-12-24 07:54:55 UTC
Permalink
JJ,
Post by 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) ?
Post by JJ
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
JJ
2020-12-24 14:30:48 UTC
Permalink
Post by R.Wieser
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.
Loading...