Показать сообщение отдельно
  #3  
Старый 24.01.2013, 17:28
icWasya icWasya вне форума
Местный
 
Регистрация: 09.11.2010
Сообщения: 499
Репутация: 10
По умолчанию

только наверно лучше не
Код:
var shape : array [1..16] of TShape;
а
Код:
var shape : array [1..4,1..4] of TShape;

и затем
Код:
// изменение цвета
procedure TForm1.SetCellColor(I,J:Integer;B:Boolean);
var
  C:TColor;
begin
  if B then C:=clRed else C:=clBlue;
  with shape[i,j] do 
  begin
    Pen.Color:=C;
    Brush.Color:=C;
  end;
end;
procedure TForm1.InvertCellColor(I,J:Integer);
var
  C:TColor;
begin
  with shape[i,j] do 
  begin
    if Brush.Color = clBlue then C:=clRed else C:=clBlue;
    Pen.Color:=C;
    Brush.Color:=C;
  end;
end;
и
Код:
procedure TForm1.InitColors;
var i,j,R:integer;
begin
   for i:=1 to 4 do for j := 1 to 4 do
   begin
     R:=Random(2);(* не забыть где нибудь в FormCreate вызвать Randomize *)
     SetCellColor(I,J , R < 1 );
   end;
end;
Ответить с цитированием