This the code for maXbox scripting:
procedure SetArrayLength2Panels(var arr: array of array of TPanel;
asize1, asize2: Integer);
var i: Integer;
begin setlength(arr, asize1);
for i:= 0 to asize1-1 do SetLength(arr[i], asize2);
end;
procedure TMyFormInitialisePanels(aform: Tform; RowCount,ColCount: Integer);
var
aLeft,aTop,aWidth,aHeight, row,col: Integer;
Panel: TPanel;
FPanels: array of array of TPanel;
begin
//SetLength(FPanels, RowCount, ColCount);
SetArrayLength2Panels(Fpanels, RowCount, ColCount)
aTop:= 0;
for Row:= 0 to RowCount-1 do begin
aLeft:= 0;
aHeight:= (aform.ClientHeight-aTop) div (RowCount-Row);
for Col:= 0 to ColCount-1 do begin
Panel:= TPanel.Create(Self);
FPanels[Row][Col]:= Panel;
Panel.Parent:= aform; //Self;
//panel.parentcolor:= false;
panel.ParentBackground:= false;
panel.color:= random(clred)
aWidth:= (aform.ClientWidth-aLeft) div (ColCount-Col);
Panel.SetBounds(aLeft, aTop, aWidth, aHeight);
inc2(aLeft, aWidth);
end;
inc2(aTop, aHeight);
end;
end;