Designer: TScrollingWinControl paints design-time grid only on visible area. Issue #39866. Based on work by German forum user "siro".

(cherry picked from commit b9c4368fce)
This commit is contained in:
wp_xyz 2022-08-25 09:57:47 +02:00 committed by Maxim Ganetsky
parent ed085d959f
commit 8c898cd63a

View File

@ -3185,6 +3185,11 @@ begin
end;
end;
function RoundToMultiple(AValue, ABasis: Integer): Integer; inline;
begin
Result := AValue div ABasis * ABasis;
end;
procedure TDesigner.PaintClientGrid(AWinControl: TWinControl;
aDDC: TDesignerDeviceContext);
var
@ -3192,6 +3197,8 @@ var
Count: integer;
i: integer;
CurControl: TControl;
R, R1: TRect;
P: TPoint;
begin
if (AWinControl=nil)
or (not (csAcceptsControls in AWinControl.ControlStyle))
@ -3218,8 +3225,11 @@ begin
ADDC.Canvas.Pen.Color := GridColor;
ADDC.Canvas.Pen.Width := 1;
ADDC.Canvas.Pen.Style := psSolid;
DrawGrid(ADDC.Canvas.Handle, TWinControlAccess(AWinControl).GetLogicalClientRect,
GridSizeX, GridSizeY);
P := TWinControlAccess(AWinControl).GetClientScrollOffset;
R := AWinControl.ClientRect;
R.BottomRight := R.BottomRight + Point(GridSizeX, GridSizeY);
OffsetRect(R, RoundToMultiple(P.X, GridSizeX), RoundToMultiple(P.Y, GridSizeY));
DrawGrid(ADDC.Canvas.Handle, R, GridSizeX, GridSizeY);
end;
if ShowBorderSpacing then