Вот весь код процедуры:
Код:
procedure TForm1.Button1Click(Sender: TObject);
var
i, x, y : integer;
tm : TTimer;
pb : TProgressBar;
lb : TLabel;
Msg:TWMGetMinMaxInfo;
Grid : array[0..16] of TDrawGrid;
Text : array[0..16] of TLabel;
begin
i:= 0;// Нове вікно? з "даними тестування" + посил на принтер
if Timer1<>Nil then
Timer1.Free;
for i := 1 to 11 do
begin
pb := bars[i-1];
lb := labels[i-1];
if pb<>Nil then
begin
pb.Visible := false;
pb.Free;
lb.Free;
end;
end;
x := screen.Width;
y := screen.Height;
Form1.Left := (x-1168) div 2;
Form1.Top := y-800;
Form1.Width := 1170;
Button1.Free;
Height := 700;
// Агресія
Text[0] := TLabel.Create(Form1);
Text[0].Parent :=Form1;
Text[0].Caption := 'Агресія';
Text[0].Left := 30;
Grid[0] := TDrawGrid.Create(Form1);
Grid[0].Tag := 1;
Grid[0].Parent := Form1;
Grid[0].Height := 6*agres;
Grid[0].Left := 1;
Grid[0].Top := Grid[0].Height - 600+20;
Grid[0].RowCount := 1;
Grid[0].ColCount := 1;
Grid[0].Enabled := false;
Grid[0].DefaultColWidth := 100;
Grid[0].DefaultRowHeight := 6*agres;
Grid[0].Width := 100;
Grid[0].ScrollBars := ssNone;
Grid[0].OnDrawCell:=DrawGrid1DrawCell;
// Алкоголь
Text[1] := TLabel.Create(Form1);
Text[1].Parent :=Form1;
Text[1].Caption := 'Алкоголь';
Text[1].Left := 130;
Grid[1] := TDrawGrid.Create(Form1);
Grid[1].Parent := Form1;
Grid[1].Left := 106;
Grid[1].Tag := 2;
Grid[1].RowCount := 1;
Grid[1].ColCount := 1;
Grid[1].Enabled := false;
Grid[1].DefaultColWidth := 100;
Grid[1].DefaultRowHeight := 6*alcohol;
Grid[1].Width := 100;
Grid[1].Height := 6*alcohol;
Grid[1].Top := 600-6*alcohol + 20;
Grid[1].ScrollBars := ssNone;
Grid[1].OnDrawCell:=DrawGrid1DrawCell;
// Алкоголь
Text[2] := TLabel.Create(Form1);
Text[2].Parent :=Form1;
Text[2].Caption := 'Шеф';
Text[2].Left := 250;
Grid[2] := TDrawGrid.Create(Form1);
Grid[2].Parent := Form1;
Grid[2].Left := 211;
Grid[2].RowCount := 1;
Grid[2].ColCount := 1;
Grid[2].Enabled := false;
Grid[2].DefaultColWidth := 100;
Grid[2].DefaultRowHeight := 6*boss;
Grid[2].Width := 100;
Grid[2].Height := 6*boss;
Grid[2].Top := 600-Grid[2].Height+20;
Grid[2].ScrollBars := ssNone;
Grid[2].Tag := 3;
Grid[2].OnDrawCell:=DrawGrid1DrawCell;
// Депресія
Text[3] := TLabel.Create(Form1);
Text[3].Parent :=Form1;
Text[3].Caption := 'Депресія';
Text[3].Left := 345;
Grid[3] := TDrawGrid.Create(Form1);
Grid[3].Parent := Form1;
Grid[3].Left := 316;
Grid[3].RowCount := 1;
Grid[3].ColCount := 1;
Grid[3].Enabled := false;
Grid[3].DefaultColWidth := 100;
Grid[3].DefaultRowHeight := 6*depression;
Grid[3].Width := 100;
Grid[3].Height := 6*depression;
Grid[3].Top := 600-Grid[3].Height+20;
Grid[3].ScrollBars := ssNone;
Grid[3].Tag := 4;
Grid[3].OnDrawCell:=DrawGrid1DrawCell;
// Борги
Text[4] := TLabel.Create(Form1);
Text[4].Parent :=Form1;
Text[4].Caption := 'Борги';
Text[4].Left := 435;
Grid[4] := TDrawGrid.Create(Form1);
Grid[4].Parent := Form1;
Grid[4].Left := 421;
Grid[4].RowCount := 1;
Grid[4].ColCount := 1;
Grid[4].Enabled := false;
Grid[4].DefaultColWidth := 100;
Grid[4].DefaultRowHeight := 6*debts;
Grid[4].Width := 100;
Grid[4].Height := 6*debts;
Grid[4].Top := 600-Grid[4].Height+20;
Grid[4].ScrollBars := ssNone;
Grid[4].Tag := 5;
Grid[4].OnDrawCell:=DrawGrid1DrawCell;
// Зарплата
Text[5] := TLabel.Create(Form1);
Text[5].Parent :=Form1;
Text[5].Caption := 'Зарплата';
Text[5].Left := 540;
Grid[5] := TDrawGrid.Create(Form1);
Grid[5].Parent := Form1;
Grid[5].Left := 526;
Grid[5].RowCount := 1;
Grid[5].ColCount := 1;
Grid[5].Enabled := false;
Grid[5].DefaultColWidth := 100;
Grid[5].DefaultRowHeight := 6*salary;
Grid[5].Width := 100;
Grid[5].Height := 6*salary;
Grid[5].Top := 600-Grid[5].Height+20;
Grid[5].ScrollBars := ssNone;
Grid[5].Tag := 6;
Grid[5].OnDrawCell:=DrawGrid1DrawCell;
// Інформація
Text[6] := TLabel.Create(Form1);
Text[6].Parent :=Form1;
Text[6].Caption := 'Інформація';
Text[6].Left := 630;
Grid[6] := TDrawGrid.Create(Form1);
Grid[6].Parent := Form1;
Grid[6].Left := 631;
Grid[6].RowCount := 1;
Grid[6].ColCount := 1;
Grid[6].Enabled := false;
Grid[6].DefaultColWidth := 100;
Grid[6].DefaultRowHeight := 6*information;
Grid[6].Width := 100;
Grid[6].Height := 6*information;
Grid[6].Top := 600-Grid[6].Height+20;
Grid[6].ScrollBars := ssNone;
Grid[6].Tag := 7;
Grid[6].OnDrawCell:=DrawGrid1DrawCell;
// Лідер
Text[7] := TLabel.Create(Form1);
Text[7].Parent :=Form1;
Text[7].Caption := 'Лідер';
Text[7].Left := 738;
Grid[7] := TDrawGrid.Create(Form1);
Grid[7].Parent := Form1;
Grid[7].Left := 736;
Grid[7].RowCount := 1;
Grid[7].ColCount := 1;
Grid[7].Enabled := false;
Grid[7].DefaultColWidth := 100;
Grid[7].DefaultRowHeight := 6*leader;
Grid[7].Width := 100;
Grid[7].Height := 6*leader;
Grid[7].Top := 600-Grid[7].Height+20;
Grid[7].ScrollBars := ssNone;
Grid[7].Tag := 8;
Grid[7].OnDrawCell:=DrawGrid1DrawCell;
// Статус
Text[8] := TLabel.Create(Form1);
Text[8].Parent :=Form1;
Text[8].Caption := 'Статус';
Text[8].Left := 830;
Grid[8] := TDrawGrid.Create(Form1);
Grid[8].Parent := Form1;
Grid[8].Left := 841;
Grid[8].RowCount := 1;
Grid[8].ColCount := 1;
Grid[8].Enabled := false;
Grid[8].DefaultColWidth := 100;
Grid[8].DefaultRowHeight := 6*status;
Grid[8].Width := 100;
Grid[8].Height := 6*status;
Grid[8].Top := 600-Grid[8].Height+20;
Grid[8].ScrollBars := ssNone;
Grid[8].Tag := 9;
Grid[8].OnDrawCell:=DrawGrid1DrawCell;
// Наркотики
Text[9] := TLabel.Create(Form1);
Text[9].Parent :=Form1;
Text[9].Caption := 'Наркотики';
Text[9].Left := 950;
Grid[9] := TDrawGrid.Create(Form1);
Grid[9].Parent := Form1;
Grid[9].Left := 946;
Grid[9].RowCount := 1;
Grid[9].ColCount := 1;
Grid[9].Enabled := false;
Grid[9].DefaultColWidth := 100;
Grid[9].DefaultRowHeight := 6*drugs;
Grid[9].Width := 100;
Grid[9].Height := 6*drugs;
Grid[9].Top := 600-Grid[9].Height+20;
Grid[9].ScrollBars := ssNone;
Grid[9].Tag := 10;
Grid[9].OnDrawCell:=DrawGrid1DrawCell;
// Звільнення
Text[10] := TLabel.Create(Form1);
Text[10].Parent :=Form1;
Text[10].Caption := 'Звільнення';
Text[10].Left := 1060;
Grid[10] := TDrawGrid.Create(Form1);
Grid[10].Parent := Form1;
Grid[10].Left := 1051;
Grid[10].RowCount := 1;
Grid[10].ColCount := 1;
Grid[10].Enabled := false;
Grid[10].DefaultColWidth := 100;
Grid[10].DefaultRowHeight := 6*dismissal;
Grid[10].Width := 100;
Grid[10].Height := 6*dismissal;
Grid[10].Top := 600-Grid[10].Height+20;
Grid[10].ScrollBars := ssNone;
Grid[10].Tag := 11;
Grid[10].OnDrawCell:=DrawGrid1DrawCell;
Button2.Left := (Form1.Width-Button2.Width) DIV 2;
Button2.Top := 630;
Button2.Visible := true;
end;
Причем когда запустил такой кусок кода:
Код:
for i:=0 to 16 do
begin
Text[i] := TLabel.Create(Form1);
end;
Тоже вызывает ошибку, а когда такой:
Код:
for i:=0 to 16 do
begin
ShowMessage(IntToStr(i));
Text[i] := TLabel.Create(Form1);
end;
Ошибки нет! В чем здесь ляп????