Как расположить окна в ряд ровно:

 
10 окон с графикой расположил по 5 сверху и снизу, а выровнял окна следующей процедурой ( EURUSD слева вверху, AUDUSD справа внизу ) :
procedure TForm1.Button1Click(Sender: TObject);
var h: THandle; h1: array[1..10] of THandle;
    s: String;  i, j, k, m: BYTE; l,t,r,b,hw,ww,ch,cw,nl,nt: Integer;
    sAr: Array [1..10] of String;
    Buffer: array[0..255] of Char;
    arect: TRECT;
label mt0, mt1;
begin
  sAr[1] := 'EURUSD,';
  sAr[2] := 'AUDUSD,';
  sAr[3] := 'GBPUSD,';
  sAr[4] := 'NZDUSD,';
  sAr[5] := 'USDCHF,';
  sAr[6] := 'USDCAD,';
  sAr[7] := 'USDJPY,';
  sAr[8] := 'EURJPY,';
  sAr[9] := 'GBPJPY,';
  sAr[10] := 'GBPCHF,';
  h := FindWindow('MetaQuotes::MetaTrader::4.00', nil);
  h := GetWindow(h, GW_CHILD);
  i := 0; s := GetWindowClass(h);
  while (s <> 'MDICLIENT') do
  begin
    if (i > 0) then
    h := GetWindow(h, GW_HWNDNEXT);
    s := GetWindowClass(h);
    Inc(i);
  end;
  h := GetWindow(h, GW_CHILD);
  j := 0; l:= 0; t:= 0; r:= 0; b:= 0;
  i := 0; s := GetWindowClass(h);
  while (true) do
  begin
    if (j = 0) then
      h := GetWindow(h, GW_HWNDLAST)
    else h := GetWindow(h, GW_HWNDPREV);
    if (h = 0) then break;
    SetString(s, Buffer, GetWindowText(h, Buffer, SizeOf(Buffer)));
    s := Copy(s, 1, 7);
    j := 0;
    while (true) do
    begin
      Inc(j);
      if (s = sAr[j]) then
      begin 
        Inc(i);
       mt0:
        Case j of
        1,11 :
            begin
              if (j < 11) then
                h1[j] := h
              else h := h1[1];
              GetWindowRect(h, arect);
              l := arect.Left; t := arect.Top;
              if (l+t = 0) or (r+b = 0) then goto mt1;
              hw := (b - t) div 2;
              ww := (r - l) div 5; 
              if (j < 11) then goto mt1;
              ch := (arect.Bottom + arect.Top) div 2;
              cw := (arect.Left + arect.Right) div 2;
              for k := 0 to 4 do
              begin
                nl := l + k * ww;
                if (cw > nl) and (cw < nl+ww) then
                for m := 0 to 1 do
                begin
                  nt := t + m * hw;
                  if (ch > nt) and (ch < nt+hw) then
                    SetWindowPos(h,HWND_TOP,nl-l,nt-t,ww,hw,SWP_NOOWNERZORDER);
                end;
              end;
              goto mt1;
            end;
        2,12 :
            begin
              if (j < 11) then
                h1[j] := h
              else h := h1[2];
              GetWindowRect(h, arect);
              b := arect.Bottom; r := arect.Right;
              if (l+t = 0) or (r+b = 0) then goto mt1;
              hw := (b - t) div 2;
              ww := (r - l) div 5;
              if (j < 11) then goto mt1;
              ch := (arect.Bottom + arect.Top) div 2;
              cw := (arect.Left + arect.Right) div 2;
              for k := 0 to 4 do
              begin
                nl := l + k * ww;
                if (cw > nl) and (cw < nl+ww) then
                for m := 0 to 1 do
                begin
                  nt := t + m * hw;
                  if (ch > nt) and (ch < nt+hw) then
                    SetWindowPos(h,HWND_TOP,nl-l,nt-t,ww,hw,SWP_NOOWNERZORDER);
                end;
              end;
              goto mt1;
            end;
        3,13 : 
            begin
              if (j < 11) then
                h1[j] := h
              else h := h1[3];
              if (j < 11) then goto mt1;
              GetWindowRect(h, arect);
              ch := (arect.Bottom + arect.Top) div 2;
              cw := (arect.Left + arect.Right) div 2;
              for k := 0 to 4 do
              begin
                nl := l + k * ww;
                if (cw > nl) and (cw < nl+ww) then
                for m := 0 to 1 do
                begin
                  nt := t + m * hw;
                  if (ch > nt) and (ch < nt+hw) then
                    SetWindowPos(h,HWND_TOP,nl-l,nt-t,ww,hw,SWP_NOOWNERZORDER);
                end;
              end;
              goto mt1;
            end;
        4,14 : 
            begin
              if (j < 11) then
                h1[j] := h
              else h := h1[4];
              if (j < 11) then goto mt1;
              GetWindowRect(h, arect);
              ch := (arect.Bottom + arect.Top) div 2;
              cw := (arect.Left + arect.Right) div 2;
              for k := 0 to 4 do
              begin
                nl := l + k * ww;
                if (cw > nl) and (cw < nl+ww) then
                for m := 0 to 1 do
                begin
                  nt := t + m * hw;
                  if (ch > nt) and (ch < nt+hw) then
                    SetWindowPos(h,HWND_TOP,nl-l,nt-t,ww,hw,SWP_NOOWNERZORDER);
                end;
              end;
              goto mt1;
            end;
        5,15 : 
            begin
              if (j < 11) then
                h1[j] := h
              else h := h1[5];
              if (j < 11) then goto mt1;
              GetWindowRect(h, arect);
              ch := (arect.Bottom + arect.Top) div 2;
              cw := (arect.Left + arect.Right) div 2;
              for k := 0 to 4 do
              begin
                nl := l + k * ww;
                if (cw > nl) and (cw < nl+ww) then
                for m := 0 to 1 do
                begin
                  nt := t + m * hw;
                  if (ch > nt) and (ch < nt+hw) then
                    SetWindowPos(h,HWND_TOP,nl-l,nt-t,ww,hw,SWP_NOOWNERZORDER);
                end;
              end;
              goto mt1;
            end;
        6,16 :
            begin
              if (j < 11) then
                h1[j] := h
              else h := h1[6];
              if (j < 11) then goto mt1;
              GetWindowRect(h, arect);
              ch := (arect.Bottom + arect.Top) div 2;
              cw := (arect.Left + arect.Right) div 2;
              for k := 0 to 4 do
              begin
                nl := l + k * ww;
                if (cw > nl) and (cw < nl+ww) then
                for m := 0 to 1 do
                begin
                  nt := t + m * hw;
                  if (ch > nt) and (ch < nt+hw) then
                    SetWindowPos(h,HWND_TOP,nl-l,nt-t,ww,hw,SWP_NOOWNERZORDER);
                end;
              end;
              goto mt1;
            end;
        7,17 :
            begin
              if (j < 11) then
                h1[j] := h
              else h := h1[7];
              if (j < 11) then goto mt1;
              GetWindowRect(h, arect);
              ch := (arect.Bottom + arect.Top) div 2;
              cw := (arect.Left + arect.Right) div 2;
              for k := 0 to 4 do
              begin
                nl := l + k * ww;
                if (cw > nl) and (cw < nl+ww) then
                for m := 0 to 1 do
                begin
                  nt := t + m * hw;
                  if (ch > nt) and (ch < nt+hw) then
                    SetWindowPos(h,HWND_TOP,nl-l,nt-t,ww,hw,SWP_NOOWNERZORDER);
                end;
              end;
              goto mt1;
            end;
        8,18 : 
            begin
              if (j < 11) then
                h1[j] := h
              else h := h1[8];
              if (j < 11) then goto mt1;
              GetWindowRect(h, arect);
              ch := (arect.Bottom + arect.Top) div 2;
              cw := (arect.Left + arect.Right) div 2;
              for k := 0 to 4 do
              begin
                nl := l + k * ww;
                if (cw > nl) and (cw < nl+ww) then
                for m := 0 to 1 do
                begin
                  nt := t + m * hw;
                  if (ch > nt) and (ch < nt+hw) then
                    SetWindowPos(h,HWND_TOP,nl-l,nt-t,ww,hw,SWP_NOOWNERZORDER);
                end;
              end;
              goto mt1;
            end;
        9,19 : 
            begin
              if (j < 11) then
                h1[j] := h
              else h := h1[9];
              if (j < 11) then goto mt1;
              GetWindowRect(h, arect);
              ch := (arect.Bottom + arect.Top) div 2;
              cw := (arect.Left + arect.Right) div 2;
              for k := 0 to 4 do
              begin
                nl := l + k * ww;
                if (cw > nl) and (cw < nl+ww) then
                for m := 0 to 1 do
                begin
                  nt := t + m * hw;
                  if (ch > nt) and (ch < nt+hw) then
                    SetWindowPos(h,HWND_TOP,nl-l,nt-t,ww,hw,SWP_NOOWNERZORDER);
                end;
              end;
              goto mt1;
            end;
        10,20:
            begin
              if (j < 11) then
                h1[j] := h
              else h := h1[10];
              if (j < 11) then goto mt1;
              GetWindowRect(h, arect);
              ch := (arect.Bottom + arect.Top) div 2;
              cw := (arect.Left + arect.Right) div 2;
              for k := 0 to 4 do
              begin
                nl := l + k * ww;
                if (cw > nl) and (cw < nl+ww) then
                for m := 0 to 1 do
                begin
                  nt := t + m * hw;
                  if (ch > nt) and (ch < nt+hw) then
                    SetWindowPos(h,HWND_TOP,nl-l,nt-t,ww,hw,SWP_NOOWNERZORDER);
                end;
              end;
              goto mt1;
            end;
        end;
      end;
    end;
    mt1:
    if (i >= 10) then
    begin
      Inc(i);
      if (i > 20) then break;
      j := i;
      goto mt0;
    end;
  end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var h: THandle; h1: array[1..10] of THandle;
    s: String;  i, j, k, m: BYTE; l,t,r,b,hw,ww,ch,cw,nl,nt: Integer;
    sAr: Array [1..10] of String;
    Buffer: array[0..255] of Char;
    arect: TRECT;
label mt0, mt1;
begin
  sAr[1] := 'EURUSD,';
  sAr[2] := 'AUDUSD,';
  sAr[3] := 'GBPUSD,';
  sAr[4] := 'NZDUSD,';
  sAr[5] := 'USDCHF,';
  sAr[6] := 'USDCAD,';
  sAr[7] := 'USDJPY,';
  sAr[8] := 'EURJPY,';
  sAr[9] := 'GBPJPY,';
  sAr[10] := 'GBPCHF,';
  h := FindWindow('MetaQuotes::MetaTrader::4.00', nil);
  h := GetWindow(h, GW_CHILD);
  i := 0; s := GetWindowClass(h);
  while (s <> 'MDICLIENT') do
  begin
    if (i > 0) then
    h := GetWindow(h, GW_HWNDNEXT);
    s := GetWindowClass(h);
    Inc(i);
  end;
  h := GetWindow(h, GW_CHILD);
  j := 0; l:= 0; t:= 0; r:= 0; b:= 0;
  i := 0; s := GetWindowClass(h);
  while (true) do
  begin
    if (j = 0) then
      h := GetWindow(h, GW_HWNDLAST)
    else h := GetWindow(h, GW_HWNDPREV);
    if (h = 0) then break;
    SetString(s, Buffer, GetWindowText(h, Buffer, SizeOf(Buffer)));
    s := Copy(s, 1, 7);
    j := 0;
    while (true) do
    begin
      Inc(j);
      if (s = sAr[j]) then
      begin 
        Inc(i);
       mt0:
        Case j of
        1,11 :
            begin
              if (j < 11) then
                h1[j] := h
              else h := h1[1];
              GetWindowRect(h, arect);
              l := arect.Left; t := arect.Top;
              if (l+t = 0) or (r+b = 0) then goto mt1;
              hw := (b - t) div 2;
              ww := (r - l) div 5; 
              if (j < 11) then goto mt1;
              ch := (arect.Bottom + arect.Top) div 2;
              cw := (arect.Left + arect.Right) div 2;
              for k := 0 to 4 do
              begin
                nl := l + k * ww;
                if (cw > nl) and (cw < nl+ww) then
                for m := 0 to 1 do
                begin
                  nt := t + m * hw;
                  if (ch > nt) and (ch < nt+hw) then
                    SetWindowPos(h,HWND_TOP,nl-l,nt-t,ww,hw,SWP_NOOWNERZORDER);
                end;
              end;
              goto mt1;
            end;
        2,12 :
            begin
              if (j < 11) then
                h1[j] := h
              else h := h1[2];
              GetWindowRect(h, arect);
              b := arect.Bottom; r := arect.Right;
              if (l+t = 0) or (r+b = 0) then goto mt1;
              hw := (b - t) div 2;
              ww := (r - l) div 5;
              if (j < 11) then goto mt1;
              ch := (arect.Bottom + arect.Top) div 2;
              cw := (arect.Left + arect.Right) div 2;
              for k := 0 to 4 do
              begin
                nl := l + k * ww;
                if (cw > nl) and (cw < nl+ww) then
                for m := 0 to 1 do
                begin
                  nt := t + m * hw;
                  if (ch > nt) and (ch < nt+hw) then
                    SetWindowPos(h,HWND_TOP,nl-l,nt-t,ww,hw,SWP_NOOWNERZORDER);
                end;
              end;
              goto mt1;
            end;
        3,13 : 
            begin
              if (j < 11) then
                h1[j] := h
              else h := h1[3];
              if (j < 11) then goto mt1;
              GetWindowRect(h, arect);
              ch := (arect.Bottom + arect.Top) div 2;
              cw := (arect.Left + arect.Right) div 2;
              for k := 0 to 4 do
              begin
                nl := l + k * ww;
                if (cw > nl) and (cw < nl+ww) then
                for m := 0 to 1 do
                begin
                  nt := t + m * hw;
                  if (ch > nt) and (ch < nt+hw) then
                    SetWindowPos(h,HWND_TOP,nl-l,nt-t,ww,hw,SWP_NOOWNERZORDER);
                end;
              end;
              goto mt1;
            end;
        4,14 : 
            begin
              if (j < 11) then
                h1[j] := h
              else h := h1[4];
              if (j < 11) then goto mt1;
              GetWindowRect(h, arect);
              ch := (arect.Bottom + arect.Top) div 2;
              cw := (arect.Left + arect.Right) div 2;
              for k := 0 to 4 do
              begin
                nl := l + k * ww;
                if (cw > nl) and (cw < nl+ww) then
                for m := 0 to 1 do
                begin
                  nt := t + m * hw;
                  if (ch > nt) and (ch < nt+hw) then
                    SetWindowPos(h,HWND_TOP,nl-l,nt-t,ww,hw,SWP_NOOWNERZORDER);
                end;
              end;
              goto mt1;
            end;
        5,15 : 
            begin
              if (j < 11) then
                h1[j] := h
              else h := h1[5];
              if (j < 11) then goto mt1;
              GetWindowRect(h, arect);
              ch := (arect.Bottom + arect.Top) div 2;
              cw := (arect.Left + arect.Right) div 2;
              for k := 0 to 4 do
              begin
                nl := l + k * ww;
                if (cw > nl) and (cw < nl+ww) then
                for m := 0 to 1 do
                begin
                  nt := t + m * hw;
                  if (ch > nt) and (ch < nt+hw) then
                    SetWindowPos(h,HWND_TOP,nl-l,nt-t,ww,hw,SWP_NOOWNERZORDER);
                end;
              end;
              goto mt1;
            end;
        6,16 :
            begin
              if (j < 11) then
                h1[j] := h
              else h := h1[6];
              if (j < 11) then goto mt1;
              GetWindowRect(h, arect);
              ch := (arect.Bottom + arect.Top) div 2;
              cw := (arect.Left + arect.Right) div 2;
              for k := 0 to 4 do
              begin
                nl := l + k * ww;
                if (cw > nl) and (cw < nl+ww) then
                for m := 0 to 1 do
                begin
                  nt := t + m * hw;
                  if (ch > nt) and (ch < nt+hw) then
                    SetWindowPos(h,HWND_TOP,nl-l,nt-t,ww,hw,SWP_NOOWNERZORDER);
                end;
              end;
              goto mt1;
            end;
        7,17 :
            begin
              if (j < 11) then
                h1[j] := h
              else h := h1[7];
              if (j < 11) then goto mt1;
              GetWindowRect(h, arect);
              ch := (arect.Bottom + arect.Top) div 2;
              cw := (arect.Left + arect.Right) div 2;
              for k := 0 to 4 do
              begin
                nl := l + k * ww;
                if (cw > nl) and (cw < nl+ww) then
                for m := 0 to 1 do
                begin
                  nt := t + m * hw;
                  if (ch > nt) and (ch < nt+hw) then
                    SetWindowPos(h,HWND_TOP,nl-l,nt-t,ww,hw,SWP_NOOWNERZORDER);
                end;
              end;
              goto mt1;
            end;
        8,18 : 
            begin
              if (j < 11) then
                h1[j] := h
              else h := h1[8];
              if (j < 11) then goto mt1;
              GetWindowRect(h, arect);
              ch := (arect.Bottom + arect.Top) div 2;
              cw := (arect.Left + arect.Right) div 2;
              for k := 0 to 4 do
              begin
                nl := l + k * ww;
                if (cw > nl) and (cw < nl+ww) then
                for m := 0 to 1 do
                begin
                  nt := t + m * hw;
                  if (ch > nt) and (ch < nt+hw) then
                    SetWindowPos(h,HWND_TOP,nl-l,nt-t,ww,hw,SWP_NOOWNERZORDER);
                end;
              end;
              goto mt1;
            end;
        9,19 : 
            begin
              if (j < 11) then
                h1[j] := h
              else h := h1[9];
              if (j < 11) then goto mt1;
              GetWindowRect(h, arect);
              ch := (arect.Bottom + arect.Top) div 2;
              cw := (arect.Left + arect.Right) div 2;
              for k := 0 to 4 do
              begin
                nl := l + k * ww;
                if (cw > nl) and (cw < nl+ww) then
                for m := 0 to 1 do
                begin
                  nt := t + m * hw;
                  if (ch > nt) and (ch < nt+hw) then
                    SetWindowPos(h,HWND_TOP,nl-l,nt-t,ww,hw,SWP_NOOWNERZORDER);
                end;
              end;
              goto mt1;
            end;
        10,20:
            begin
              if (j < 11) then
                h1[j] := h
              else h := h1[10];
              if (j < 11) then goto mt1;
              GetWindowRect(h, arect);
              ch := (arect.Bottom + arect.Top) div 2;
              cw := (arect.Left + arect.Right) div 2;
              for k := 0 to 4 do
              begin
                nl := l + k * ww;
                if (cw > nl) and (cw < nl+ww) then
                for m := 0 to 1 do
                begin
                  nt := t + m * hw;
                  if (ch > nt) and (ch < nt+hw) then
                    SetWindowPos(h,HWND_TOP,nl-l,nt-t,ww,hw,SWP_NOOWNERZORDER);
                end;
              end;
              goto mt1;
            end;
        end;
      end;
    end;
    mt1:
    if (i >= 10) then
    begin
      Inc(i);
      if (i > 20) then break;
      j := i;
      goto mt0;
    end;
  end;
end;procedure TForm1.Button1Click(Sender: TObject);
var h: THandle; h1: array[1..10] of THandle;
    s: String;  i, j, k, m: BYTE; l,t,r,b,hw,ww,ch,cw,nl,nt: Integer;
    sAr: Array [1..10] of String;
    Buffer: array[0..255] of Char;
    arect: TRECT;
label mt0, mt1;
begin
  sAr[1] := 'EURUSD,';
  sAr[2] := 'AUDUSD,';
  sAr[3] := 'GBPUSD,';
  sAr[4] := 'NZDUSD,';
  sAr[5] := 'USDCHF,';
  sAr[6] := 'USDCAD,';
  sAr[7] := 'USDJPY,';
  sAr[8] := 'EURJPY,';
  sAr[9] := 'GBPJPY,';
  sAr[10] := 'GBPCHF,';
  h := FindWindow('MetaQuotes::MetaTrader::4.00', nil);
  h := GetWindow(h, GW_CHILD);
  i := 0; s := GetWindowClass(h);
  while (s <> 'MDICLIENT') do
  begin
    if (i > 0) then
    h := GetWindow(h, GW_HWNDNEXT);
    s := GetWindowClass(h);
    Inc(i);
  end;
  h := GetWindow(h, GW_CHILD);
  j := 0; l:= 0; t:= 0; r:= 0; b:= 0;
  i := 0; s := GetWindowClass(h);
  while (true) do
  begin
    if (j = 0) then
      h := GetWindow(h, GW_HWNDLAST)
    else h := GetWindow(h, GW_HWNDPREV);
    if (h = 0) then break;
    SetString(s, Buffer, GetWindowText(h, Buffer, SizeOf(Buffer)));
    s := Copy(s, 1, 7);
    j := 0;
    while (true) do
    begin
      Inc(j);
      if (s = sAr[j]) then
      begin 
        Inc(i);
       mt0:
        Case j of
        1,11 :
            begin
              if (j < 11) then
                h1[j] := h
              else h := h1[1];
              GetWindowRect(h, arect);
              l := arect.Left; t := arect.Top;
              if (l+t = 0) or (r+b = 0) then goto mt1;
              hw := (b - t) div 2;
              ww := (r - l) div 5; 
              if (j < 11) then goto mt1;
              ch := (arect.Bottom + arect.Top) div 2;
              cw := (arect.Left + arect.Right) div 2;
              for k := 0 to 4 do
              begin
                nl := l + k * ww;
                if (cw > nl) and (cw < nl+ww) then
                for m := 0 to 1 do
                begin
                  nt := t + m * hw;
                  if (ch > nt) and (ch < nt+hw) then
                    SetWindowPos(h,HWND_TOP,nl-l,nt-t,ww,hw,SWP_NOOWNERZORDER);
                end;
              end;
              goto mt1;
            end;
        2,12 :
            begin
              if (j < 11) then
                h1[j] := h
              else h := h1[2];
              GetWindowRect(h, arect);
              b := arect.Bottom; r := arect.Right;
              if (l+t = 0) or (r+b = 0) then goto mt1;
              hw := (b - t) div 2;
              ww := (r - l) div 5;
              if (j < 11) then goto mt1;
              ch := (arect.Bottom + arect.Top) div 2;
              cw := (arect.Left + arect.Right) div 2;
              for k := 0 to 4 do
              begin
                nl := l + k * ww;
                if (cw > nl) and (cw < nl+ww) then
                for m := 0 to 1 do
                begin
                  nt := t + m * hw;
                  if (ch > nt) and (ch < nt+hw) then
                    SetWindowPos(h,HWND_TOP,nl-l,nt-t,ww,hw,SWP_NOOWNERZORDER);
                end;
              end;
              goto mt1;
            end;
        3,13 : 
            begin
              if (j < 11) then
                h1[j] := h
              else h := h1[3];
              if (j < 11) then goto mt1;
              GetWindowRect(h, arect);
              ch := (arect.Bottom + arect.Top) div 2;
              cw := (arect.Left + arect.Right) div 2;
              for k := 0 to 4 do
              begin
                nl := l + k * ww;
                if (cw > nl) and (cw < nl+ww) then
                for m := 0 to 1 do
                begin
                  nt := t + m * hw;
                  if (ch > nt) and (ch < nt+hw) then
                    SetWindowPos(h,HWND_TOP,nl-l,nt-t,ww,hw,SWP_NOOWNERZORDER);
                end;
              end;
              goto mt1;
            end;
        4,14 : 
            begin
              if (j < 11) then
                h1[j] := h
              else h := h1[4];
              if (j < 11) then goto mt1;
              GetWindowRect(h, arect);
              ch := (arect.Bottom + arect.Top) div 2;
              cw := (arect.Left + arect.Right) div 2;
              for k := 0 to 4 do
              begin
                nl := l + k * ww;
                if (cw > nl) and (cw < nl+ww) then
                for m := 0 to 1 do
                begin
                  nt := t + m * hw;
                  if (ch > nt) and (ch < nt+hw) then
                    SetWindowPos(h,HWND_TOP,nl-l,nt-t,ww,hw,SWP_NOOWNERZORDER);
                end;
              end;
              goto mt1;
            end;
        5,15 : 
            begin
              if (j < 11) then
                h1[j] := h
              else h := h1[5];
              if (j < 11) then goto mt1;
              GetWindowRect(h, arect);
              ch := (arect.Bottom + arect.Top) div 2;
              cw := (arect.Left + arect.Right) div 2;
              for k := 0 to 4 do
              begin
                nl := l + k * ww;
                if (cw > nl) and (cw < nl+ww) then
                for m := 0 to 1 do
                begin
                  nt := t + m * hw;
                  if (ch > nt) and (ch < nt+hw) then
                    SetWindowPos(h,HWND_TOP,nl-l,nt-t,ww,hw,SWP_NOOWNERZORDER);
                end;
              end;
              goto mt1;
            end;
        6,16 :
            begin
              if (j < 11) then
                h1[j] := h
              else h := h1[6];
              if (j < 11) then goto mt1;
              GetWindowRect(h, arect);
              ch := (arect.Bottom + arect.Top) div 2;
              cw := (arect.Left + arect.Right) div 2;
              for k := 0 to 4 do
              begin
                nl := l + k * ww;
                if (cw > nl) and (cw < nl+ww) then
                for m := 0 to 1 do
                begin
                  nt := t + m * hw;
                  if (ch > nt) and (ch < nt+hw) then
                    SetWindowPos(h,HWND_TOP,nl-l,nt-t,ww,hw,SWP_NOOWNERZORDER);
                end;
              end;
              goto mt1;
            end;
        7,17 :
            begin
              if (j < 11) then
                h1[j] := h
              else h := h1[7];
              if (j < 11) then goto mt1;
              GetWindowRect(h, arect);
              ch := (arect.Bottom + arect.Top) div 2;
              cw := (arect.Left + arect.Right) div 2;
              for k := 0 to 4 do
              begin
                nl := l + k * ww;
                if (cw > nl) and (cw < nl+ww) then
                for m := 0 to 1 do
                begin
                  nt := t + m * hw;
                  if (ch > nt) and (ch < nt+hw) then
                    SetWindowPos(h,HWND_TOP,nl-l,nt-t,ww,hw,SWP_NOOWNERZORDER);
                end;
              end;
              goto mt1;
            end;
        8,18 : 
            begin
              if (j < 11) then
                h1[j] := h
              else h := h1[8];
              if (j < 11) then goto mt1;
              GetWindowRect(h, arect);
              ch := (arect.Bottom + arect.Top) div 2;
              cw := (arect.Left + arect.Right) div 2;
              for k := 0 to 4 do
              begin
                nl := l + k * ww;
                if (cw > nl) and (cw < nl+ww) then
                for m := 0 to 1 do
                begin
                  nt := t + m * hw;
                  if (ch > nt) and (ch < nt+hw) then
                    SetWindowPos(h,HWND_TOP,nl-l,nt-t,ww,hw,SWP_NOOWNERZORDER);
                end;
              end;
              goto mt1;
            end;
        9,19 : 
            begin
              if (j < 11) then
                h1[j] := h
              else h := h1[9];
              if (j < 11) then goto mt1;
              GetWindowRect(h, arect);
              ch := (arect.Bottom + arect.Top) div 2;
              cw := (arect.Left + arect.Right) div 2;
              for k := 0 to 4 do
              begin
                nl := l + k * ww;
                if (cw > nl) and (cw < nl+ww) then
                for m := 0 to 1 do
                begin
                  nt := t + m * hw;
                  if (ch > nt) and (ch < nt+hw) then
                    SetWindowPos(h,HWND_TOP,nl-l,nt-t,ww,hw,SWP_NOOWNERZORDER);
                end;
              end;
              goto mt1;
            end;
        10,20:
            begin
              if (j < 11) then
                h1[j] := h
              else h := h1[10];
              if (j < 11) then goto mt1;
              GetWindowRect(h, arect);
              ch := (arect.Bottom + arect.Top) div 2;
              cw := (arect.Left + arect.Right) div 2;
              for k := 0 to 4 do
              begin
                nl := l + k * ww;
                if (cw > nl) and (cw < nl+ww) then
                for m := 0 to 1 do
                begin
                  nt := t + m * hw;
                  if (ch > nt) and (ch < nt+hw) then
                    SetWindowPos(h,HWND_TOP,nl-l,nt-t,ww,hw,SWP_NOOWNERZORDER);
                end;
              end;
              goto mt1;
            end;
        end;
      end;
    end;
    mt1:
    if (i >= 10) then
    begin
      Inc(i);
      if (i > 20) then break;
      j := i;
      goto mt0;
    end;
  end;
end;
 
function GetWindowClass(hwnd: THandle): string;
var
  s: array[0..MAX_PATH - 1] of Char;
begin
  GetClassName(hwnd, s, Length(s));
  Result := UpperCase(s);
end;
 
Желающие наверное могут в MQL перевести.