to desertsmoke:
楼上的说的对,我同意他的观点,下面是显示网格代码,对齐的代码很简单,我就不提供了。
var
I, J, HStart, HEnd, VStart, VEnd, HCount, VCount, X, Y, SizeX,SizeY: Integer;
begin
SizeX := 8;
SizeY := 8;
if not (FSenderForm is TProxyForm) then Exit;
with FSenderForm do
begin
Canvas.Pen.width := 1;
Canvas.Pen.Mode := pmNot;
VStart := (Canvas.ClipRect.Top div SizeY) * SizeY;
VEnd := (Canvas.ClipRect.Bottom div SizeY) * SizeY;
HStart := (Canvas.ClipRect.Left div SizeX) * SizeX;
HEnd := (Canvas.ClipRect.Right div SizeX) * SizeX;
HCount := (HEnd - HStart) div SizeX + 1;
VCount := (VEnd - VStart) div SizeY + 1;
Y := VStart;
for I := 1 to VCount do
begin
X := HStart;
for J := 1 to HCount do
begin
Canvas.moveto(X, Y);
Canvas.LineTo(X+1, Y+1);
X := X + SizeX;
end;
Y := Y + SizeY;
end;
end;