TListView: Cleanup, Mouse events

git-svn-id: trunk@63029 -
This commit is contained in:
martin 2020-04-20 10:36:12 +00:00
parent 7125b6ce7e
commit 3bb99ddac4

View File

@ -793,36 +793,45 @@ begin
end; end;
WM_LBUTTONDOWN, WM_RBUTTONDOWN: WM_LBUTTONDOWN, WM_RBUTTONDOWN:
begin begin
// A ListView doesn't get a WM_LBUTTONUP, WM_RBUTTONUP message, (*
// because it keeps the message in its own event loop, A ListView doesn't get a WM_LBUTTONUP, WM_RBUTTONUP message,
// see msdn article about "Default List-View Message Processing" because it keeps the message in its own event loop,
// therefore we take this notification and create a see msdn article about "Default List-View Message Processing"
// LM_LBUTTONUP, LM_RBUTTONUP message out of it therefore we take this notification and create a
LM_LBUTTONUP, LM_RBUTTONUP message out of it.
- When the ListView starts dragging (LVN_BEGIN(R)DRAG), it will get the
mouse up
- The WindProg for the WM_LBUTTONUP, WM_RBUTTONUP does not always
return immediately (multi select). It will return on either mouse up
or BeginDrag.
The LCL mouse down event is executed with the same delay.
- Also see issue #33330
*)
WindowInfo := GetWin32WindowInfo(Window); WindowInfo := GetWin32WindowInfo(Window);
ListView := TListView(WindowInfo^.WinControl); ListView := TListView(WindowInfo^.WinControl);
ListItem := ListView.GetItemAt(GET_X_LPARAM(LParam), GET_Y_LPARAM(LParam)); ListItem := ListView.GetItemAt(GET_X_LPARAM(LParam), GET_Y_LPARAM(LParam));
if Msg = WM_LBUTTONDOWN
then AMsg := LM_LBUTTONUP
else AMsg := LM_RBUTTONUP;
ListViewWindProcInfo.ActiveListView := ListView; ListViewWindProcInfo.ActiveListView := ListView;
ListViewWindProcInfo.NoMouseUp := False; ListViewWindProcInfo.NoMouseUp := False;
try try
if Msg = WM_LBUTTONDOWN
then AMsg := LM_LBUTTONUP
else AMsg := LM_RBUTTONUP;
Result := WindowProc(Window, Msg, WParam, LParam); Result := WindowProc(Window, Msg, WParam, LParam);
// for multiselected listbox the message has to be send after current
// message or the list item selecting does not work, also see issue #33330
if (not ListViewWindProcInfo.NoMouseUp) and
(Assigned(ListItem) or ListView.MultiSelect)
then
begin
MPos := GetClientCursorPos(Window);
PostMessage(Window, AMsg, 0, MakeLParam(MPos.X, MPos.Y));
end;
finally finally
ListViewWindProcInfo.ActiveListView:= nil; ListViewWindProcInfo.ActiveListView:= nil;
end; end;
if (not ListViewWindProcInfo.NoMouseUp) and
(Assigned(ListItem) or ListView.MultiSelect)
then
begin
MPos := GetClientCursorPos(Window);
PostMessage(Window, AMsg, 0, Windows.MakeLParam(MPos.X, MPos.Y));
end;
exit; exit;
end; end;
end; end;