LCL: Clarify code in TWinControl.ControlAtPos. Rename GetControlAtPos -> ControlIsHit.

This commit is contained in:
Juha 2023-09-09 13:08:58 +03:00
parent 6eb18a2d11
commit fabfdeb599

View File

@ -5159,7 +5159,7 @@ var
LControl: TControl; LControl: TControl;
ClientBounds: TRect; ClientBounds: TRect;
function GetControlAtPos(AControl: TControl): Boolean; function ControlIsHit(AControl: TControl): Boolean;
var var
ControlPos: TPoint; ControlPos: TPoint;
begin begin
@ -5172,29 +5172,19 @@ var
if Result and (capfOnlyClientAreas in Flags) then if Result and (capfOnlyClientAreas in Flags) then
Result := PtInRect(ClientRect, ControlPos); Result := PtInRect(ClientRect, ControlPos);
Result := Result if Result then
and ( if csDesigning in ComponentState then
( // Here was a VCL bug: VCL checks if control is Visible,
(csDesigning in ComponentState) // which should be ignored at designtime
and not (csNoDesignVisible in ControlStyle) Result := not (csNoDesignVisible in ControlStyle)
// Here was a VCL bug: VCL checks if control is Visible, else
// which should be ignored at designtime Result := Visible
) and (Enabled or (capfAllowDisabled in Flags))
or and (Perform(CM_HITTEST, 0,
( LParam(Integer(PointToSmallPointNoChecks(ControlPos)))) <> 0);
(not (csDesigning in ComponentState))
and
(Visible)
and
(Enabled or (capfAllowDisabled in Flags))
and
(Perform(CM_HITTEST, 0,
LParam(Integer(PointToSmallPointNoChecks(ControlPos)))) <> 0)
)
);
{$IFDEF VerboseMouseBugfix} {$IFDEF VerboseMouseBugfix}
//if Result then //if Result then
DebugLn(['GetControlAtPos ',Name,':',ClassName, DebugLn(['ControlIsHit ',Name,':',ClassName,
' Pos=',Pos.X,',',Pos.Y, ' Pos=',Pos.X,',',Pos.Y,
' P=',P.X,',',P.Y, ' P=',P.X,',',P.Y,
' ControlPos=',dbgs(ControlPos), ' ControlPos=',dbgs(ControlPos),
@ -5249,13 +5239,13 @@ begin
if (capfAllowWinControls in Flags) then if (capfAllowWinControls in Flags) then
for I := FControls.Count - 1 downto 0 do for I := FControls.Count - 1 downto 0 do
if (TObject(FControls[i]) is TWinControl) if (TObject(FControls[i]) is TWinControl)
and GetControlAtPos(TControl(FControls[I])) then and ControlIsHit(TControl(FControls[I])) then
Break; Break;
// check controls // check controls
if (LControl = nil) and not(capfOnlyWinControls in Flags) then if (LControl = nil) and not(capfOnlyWinControls in Flags) then
for I := FControls.Count - 1 downto 0 do for I := FControls.Count - 1 downto 0 do
if (not (TObject(FControls[i]) is TWinControl)) if (not (TObject(FControls[i]) is TWinControl))
and GetControlAtPos(TControl(FControls[I])) then and ControlIsHit(TControl(FControls[I])) then
Break; Break;
end; end;
Result := LControl; Result := LControl;