![]() |
|
|
|||||||
| Регистрация | << Правила форума >> | FAQ | Пользователи | Календарь | Поиск | Сообщения за сегодня | Все разделы прочитаны |
![]() |
|
|
Опции темы | Поиск в этой теме | Опции просмотра |
|
#1
|
|||
|
|||
|
у меня на форме динамически создаэтся 11 прогрессбаров:
Код:
bars[i] := TProgressBar.Create(Form1);
bars[i].Parent := Form1;
bars[i].Left := 22;
bars[i].Width := 521;
bars[i].Top := 22+40*i;Пробывал так: Код:
procedure TForm1.Timer1Timer(Sender: TObject);
var
pb : TProgressBar;
i : integer;
begin
pb := TProgressBar(FindComponent('bars[' + IntToStr(i)+']'));
if Assigned(pb) then
begin
pb.Position := pb.Position + 1;
if pb.Position >= 100 then
inc(pBar);
if pBar > 11 then
begin
Timer1.Enabled := False;
Button1.Enabled := true;
end;
end;
end;
Ясно что я неправильно выбираю прогресбары. Как их ПРАВИЛЬНО выбирать? |
|
#2
|
||||
|
||||
|
Код:
pb := bars[i]; |
|
#3
|
|||
|
|||
|
Код понял, а как сделать полем формы?
У меня bars : array[0..10] of TProgressBar; переменная формы Теперь возник такой вопрос. К прогресбару из таймера я обращаюсь радномно и надо если у ВСЕХ прогресбаров позиция больше или равна 100 произвести определенные действия. Как это красвио написать? Там вроде надо ксор использовать... И еще (код у меня пока далеко не оптимальный) но всеже хочу понять почему во время выполнения программы возникает ошибка времени выполнения "Access violation at adress 00403414 min module. Read of adress 00A28000"? Кто может здесь помочь? Последний раз редактировалось M.A.D.M.A.N., 25.03.2013 в 19:23. |
|
#4
|
||||
|
||||
|
Цитата:
|
|
#5
|
||||
|
||||
|
AV - доступ к компоненту/переменной/объекту, который отсутствует в памяти. Это может быть, например, выход за границы динамического массива. Посмотри, где появляется эта ошибка, и пройдись по функции (целиком) в отладчике. Там увидишь, где ошибка.
|
|
#6
|
||||
|
||||
|
1. В вашем коде на срабатывание таймера совершенно не ясно какой бар вы обрабатываете. Чему равен индекс массива i ?
2. Вот что вы хотели сказать в этой строчке кода? Код:
if pBar > 11 then
begin |
|
#7
|
||||
|
||||
|
Привет, давно не виделись
![]() Код:
if pb.Position >= 100 then
inc(pBar);
if pBar > 11 then![]() Последний раз редактировалось PhoeniX, 24.03.2013 в 13:30. |
|
#8
|
||||
|
||||
|
Цитата:
|
|
#9
|
|||
|
|||
|
ПРИ дебаге, он меня выкидывает в
Код:
begin Application.Initialize; Application.CreateForm(TForm1, Form1); Application.Run; end. Я нашел какой кусок кода вызывает ошибку: Код:
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; Последний раз редактировалось M.A.D.M.A.N., 25.03.2013 в 19:24. |
|
#10
|
||||
|
||||
|
В каком методе этот код? И в какой строчке вылетает?
|
|
#11
|
|||
|
|||
|
Цитата:
Код:
Text[4] := TLabel.Create(Form1); Код:
Text[3] := TLabel.Create(Form1); P.S. Код:
Grid : array[0..16] of TDrawGrid; Text : array[0..16] of TLabel; |
|
#12
|
||||
|
||||
|
Нужно больше кода!
![]() |
|
#13
|
|||
|
|||
|
Вот весь код процедуры:
Код:
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;Последний раз редактировалось lostbananan, 24.03.2013 в 19:02. |
|
#14
|
||||
|
||||
|
Цитата:
|
|
#15
|
|||
|
|||
|
Вставил в код:
Код:
for i:=0 to 16 do begin Application.ProcessMessages; Text[i] := TLabel.Create(Form1); Application.ProcessMessages; end; Application.ProcessMessages; НИЧЕГО НЕ ВЫДАЕТ! А ошибка времени исполнения осталасб. Что делать может кто с подобным стыкался? Помогите! Я уже совсем зациклился. Код Код:
for i:=0 to 16 do
begin
ShowMessage(IntToStr(i));
Text[i] := TLabel.Create(Form1);
end;
ShowMessage('Після циклу');
Что за мистика в чем проблема может кто подскажет!!! Последний раз редактировалось M.A.D.M.A.N., 25.03.2013 в 19:23. |