From 689dde656b342a2857eec8dfa6efd4a70814849c Mon Sep 17 00:00:00 2001 From: wp_xyz Date: Wed, 11 May 2022 11:04:41 +0200 Subject: [PATCH] LCL/Listview: Fix listview jumping to first item when a key is pressed in virtual mode, issue #39715. (cherry picked from commit d3396e9fa0a410cbebf9406812979b64ec1c430a) --- .../win32/win32wscustomlistview.inc | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lcl/interfaces/win32/win32wscustomlistview.inc b/lcl/interfaces/win32/win32wscustomlistview.inc index a960e096f6..ac4ccc561f 100644 --- a/lcl/interfaces/win32/win32wscustomlistview.inc +++ b/lcl/interfaces/win32/win32wscustomlistview.inc @@ -232,6 +232,26 @@ var end; end; + { Workaround for issue #39715 to prevent the selection jumping to the first + item in virtual mode when a normal key is pressed (the listview probably + tries to perform an incremental search in this case which has not been + implemented, yet (handler for OnDataFind). } + procedure HandleListViewFindItem(ALV: TCustomlistViewAccess); + var + FindInfo: PNMLVFindItem; + listitem: TListItem; + begin + if ALV.OwnerData then + begin + FindInfo := PNMLVFindItem(NMHdr); + if Assigned(FindInfo) then + begin + MsgResult := -1; + WinProcess := false; + end; + end; + end; + begin Result := False; case Msg of @@ -246,6 +266,8 @@ begin if ListViewWindProcInfo.ActiveListView = AWinControl then ListViewWindProcInfo.NoMouseUp := True; end; + LVN_ODFINDITEM: + HandleListViewFindItem(TCustomListViewAccess(AWinControl)); end; end; end;