also i would like to create the boxes underneath the boxes, so for example i want to create 2*5 boxes; 5 at the top and 5 underneath those 5 boxes. but all same sizes.
You already had some code where you created a second My
sBoxes (with an s). But in that case you would need to check 2 arrays to see if your white box hits one of them. It's easier to create all those boxes (including 2nd, 3rd and 4th row etc) in that one array.
You would still have your main loop to create those boxes:
for i := 0 to (hplength - 1) do // dynamic arrays are 0-based
begin
MyBoxes[i] := TShape.Create(Self);
But set hplength to rows * boxes per row.
Before the loop you assign a special counter for Left (currentLeft) and Top (currentTop) the start values.
In the loop you assign currentLeft and currentTop to Left and Top of that Box.
Then you increase currentLeft with say 30 and check if that value is above 150 (or other value).
If it is, you reset currentLeft to the most left value again and increase top by 30.
I had some ready made code but try to do it like above yourself first.