最近做了个类似的,改了一下贴上来[]
type
TRectList = Array of Array of TRect;
procedure SplitScreen(x,y: Integer; var RectList: TRectList;
ScreenWidth: Integer = 1024; ScreenHeight: Integer = 768);
var
i,j: Integer;
ix,iy,iTop,iBottom: Integer;
begin
if (x<=0) or (y<=0) or (x>ScreenWidth) or (y>ScreenHeight) then
Raise Exception.Create('无效值');
ix:=ScreenWidth div x;
iy:=ScreenHeight div y;
SetLength(RectList,y,x);
for i:=0 to y-1 do
begin
iTop:=i*iy;
if i=y-1 then
iBottom:=ScreenHeight-1
else
iBottom:=iTop+iy-1;
for j:=0 to x-1 do
begin
with RectList[j] do
begin
Top:=iTop;
Bottom:=iBottom;
Left:=j*ix;
if j=x-1 then
Right:=ScreenWidth-1
else
Right:=Left+ix-1;
end;
end;
end;
end;