mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-29 10:10:31 +02:00
LCL-Win32: Call TListView OnMouseUp only once. Issue #27189, patch from Michl.
git-svn-id: trunk@51471 -
This commit is contained in:
parent
db51e758b5
commit
9eff7f69ea
@ -215,6 +215,16 @@ var
|
||||
end;
|
||||
end;
|
||||
|
||||
function OwnMouseUpNeeded(ALV: TCustomListViewAccess): Boolean;
|
||||
var
|
||||
LVInfo: PWin32WindowInfo;
|
||||
ListItem: TListItem;
|
||||
begin
|
||||
LVInfo:= GetWin32WindowInfo(ALV.Handle);
|
||||
ListItem := ALV.GetItemAt(LVInfo^.MouseX, LVInfo^.MouseY);
|
||||
Result := Assigned(ListItem);
|
||||
end;
|
||||
|
||||
var
|
||||
Pos: TSmallPoint;
|
||||
begin
|
||||
@ -224,25 +234,24 @@ begin
|
||||
begin
|
||||
case PNMHdr(LParam)^.code of
|
||||
NM_CLICK, NM_RCLICK:
|
||||
begin
|
||||
// A listview doesn't get a WM_LBUTTONUP, WM_RBUTTONUP message,
|
||||
// because it keeps the message in its own event loop,
|
||||
// see msdn article about "Default List-View Message Processing"
|
||||
// therefore we take this notification and create a
|
||||
// LM_LBUTTONUP, LM_RBUTTONUP message out of it
|
||||
WinProcess := False;
|
||||
if PNMHdr(LParam)^.code = NM_CLICK then
|
||||
Msg := LM_LBUTTONUP
|
||||
else
|
||||
Msg := LM_RBUTTONUP;
|
||||
Pos := GetClientCursorPos(PNMHdr(LParam)^.hwndFrom);
|
||||
// to make correct event sequence in LCL we should postpone this message
|
||||
// since we are here after call of CallDefaultWindowProc
|
||||
|
||||
// TODO: prevent getting more than one Up, Down message by LCL
|
||||
PostMessage(PNMHdr(LParam)^.hwndFrom, Msg, 0, MakeLParam(Pos.x, Pos.y));
|
||||
Result := True;
|
||||
end;
|
||||
if OwnMouseUpNeeded(TCustomListViewAccess(AWinControl)) then
|
||||
begin
|
||||
// A listview doesn't get a WM_LBUTTONUP, WM_RBUTTONUP message,
|
||||
// because it keeps the message in its own event loop,
|
||||
// see msdn article about "Default List-View Message Processing"
|
||||
// therefore we take this notification and create a
|
||||
// LM_LBUTTONUP, LM_RBUTTONUP message out of it
|
||||
WinProcess := False;
|
||||
if PNMHdr(LParam)^.code = NM_CLICK then
|
||||
Msg := LM_LBUTTONUP
|
||||
else
|
||||
Msg := LM_RBUTTONUP;
|
||||
Pos := GetClientCursorPos(PNMHdr(LParam)^.hwndFrom);
|
||||
// to make correct event sequence in LCL we should postpone this message
|
||||
// since we are here after call of CallDefaultWindowProc
|
||||
PostMessage(PNMHdr(LParam)^.hwndFrom, Msg, 0, MakeLParam(Pos.x, Pos.y));
|
||||
Result := True;
|
||||
end;
|
||||
LVN_GETDISPINFOA, LVN_GETDISPINFOW:
|
||||
HandleListViewOwnerData(TCustomListViewAccess(AWinControl));
|
||||
NM_CUSTOMDRAW:
|
||||
|
Loading…
Reference in New Issue
Block a user