Witam,
męczę się już 2 dzień z błędem, którego nijak nie mogę pojąć, rozwiązać ani cokolwiek z nim zrobić. Otóż piszę program, a w nim mam takie procedury:
procedure TForm1.ListaClick (Sender: TObject) ;
var
i :integer ;
begin
try
for i:= 0 to Length(ListaStopni[NrWybranejOsoby].Zadania)-1 do
begin
TEdit(self.FindComponent('SzczegolyZadaniaZaliczone' + IntToStr(i+1))).Free ;
TShape(self.FindComponent('SzczegolyZadaniaPoleZaliczone' + IntToStr(i+1))).Free ;
TMaskEdit(self.FindComponent('SzczegolyZadaniaData' + IntToStr(i+1))).Free ;
TShape(self.FindComponent('SzczegolyZadaniaPoleData' + IntToStr(i+1))).Free ;
TMemo(self.FindComponent('SzczegolyZadaniaTresc' + IntToStr(i+1))).Free ;
TLabel(self.FindComponent('SzczegolyZadaniaLP' + IntToStr(i+1))).Free ;
TShape(self.FindComponent('SzczegolyZadaniaPoleLP' + IntToStr(i+1))).Free ;
TSpeedButton(self.FindComponent('SzczegolyZadaniaDodaj' + IntToStr(i+1))).Free ;
TSpeedButton(self.FindComponent('SzczegolyZadaniaUsun' + IntToStr(i+1))).Free ;
end ;
finally end ;
NrWybranejOsoby:= StrToInt(Copy(TLabel(Sender).Name, 6, Length(TLabel(Sender).Name)-5)) ;
for i:= 0 to Length(ListaStopni[NrWybranejOsoby].Zadania)-1 do
begin
with TShape.Create(self) do
begin
Name:= 'SzczegolyZadaniaPoleLP' + IntToStr(i+1) ;
Top:= -1 + i*59 ;
Left:= -1 ;
Width:= 27 ;
Height:= 60 ;
Brush.Color:= clBtnFace ;
Parent:= ScrollBox3 ;
Visible:= True ;
end ;
if i > 0 then
with TSpeedButton.Create(self) do
begin
Name:= 'SzczegolyZadaniaUsun' + IntToStr(i+1) ;
Top:= i*59 + 28 ;
Left:= 0 ;
Width:= 25 ;
Height:= 15 ;
Caption:= '-' ;
Visible:= True ;
Parent:= ScrollBox3 ;
Hint:= 'Usuń zadanie' ;
ShowHint:= True ;
with Font do
begin
Name:= 'Verdana' ;
Size:= 10 ;
Style:= [fsBold] ;
end ;
//OnClick:= ZadaniaUsunClick ;
end ;
with TSpeedButton.Create(self) do
begin
Name:= 'SzczegolyZadaniaDodaj' + IntToStr(i+1) ;
Top:= i*59 + 43 ;
Left:= 0 ;
Width:= 25 ;
Height:= 15 ;
Caption:= '+' ;
Visible:= True ;
Parent:= ScrollBox3 ;
Hint:= 'Dodaj nowe zadanie' ;
ShowHint:= True ;
with Font do
begin
Name:= 'Verdana' ;
Size:= 10 ;
Style:= [fsBold] ;
end ;
OnClick:= ZadaniaDodajClick ;
end ;
with TLabel.Create(self) do
begin
Name:= 'SzczegolyZadaniaLP' + IntToStr(i+1) ;
Top:= 1 + i*59 ;
Left:= 5 ;
Parent:= ScrollBox3 ;
Visible:= True ;
Caption:= IntToStr(i+1) ;
Font.Size:= 10 ;
Font.Name:= 'Verdana' ;
ShowHint:= True ;
Hint:= 'Liczba porządkowa zadania' ;
end ;
with TMemo.Create(self) do
begin
Name:= 'SzczegolyZadaniaTresc' + IntToStr(i+1) ;
Top:= -1 + i*59 ;
Left:= 25 ;
Parent:= ScrollBox3 ;
Visible:= True ;
Text:= ListaStopni[NrWybranejOsoby].Zadania[i].Tresc ;
Font.Size:= 10 ;
Font.Name:= 'Verdana' ;
Width:= 400 ;
Height:= 60 ;
ScrollBars:= ssVertical ;
WantReturns:= False ;
Ctl3D:= False ;
OnExit:= ZadaniaExit ;
Color:= clBtnFace ;
OnEnter:= ZadaniaEnter ;
OnKeyPress:= ZadaniaKeyPress ;
end ;
with TShape.Create(self) do
begin
Name:= 'SzczegolyZadaniaPoleData' + IntToStr(i+1) ;
Top:= -1 + i*59 ;
Left:= 425 ;
Width:= 60 ;
Height:= 60 ;
Brush.Color:= clBtnFace ;
Parent:= ScrollBox3 ;
Visible:= True ;
end ;
with TMaskEdit.Create(self) do
begin
Name:= 'SzczegolyZadaniaData' + IntToStr(i+1) ;
Top:= 22 + i*59 ;
Left:= 431 ;
Width:= 49 ;
Color:= clBtnFace ;
Parent:= ScrollBox3 ;
Visible:= True ;
BorderStyle:= bsNone ;
EditMask:= '99\-9999;1;_' ;
MaxLength:= 7 ;
Text:= ListaStopni[NrWybranejOsoby].Zadania[i].Data ;
Font.Name:= 'Verdana' ;
ShowHint:= True ;
Hint:= 'Przewidywany termin ukończenia zadania w formacie MM-RRRR' ;
Height:= 16 ;
OnExit:= ZadaniaExit ;
OnEnter:= ZadaniaEnter ;
OnKeyPress:= ZadaniaKeyPress ;
end ;
with TShape.Create(self) do
begin
Name:= 'SzczegolyZadaniaPoleZaliczone' + IntToStr(i+1) ;
Top:= -1 + i*59 ;
Left:= 484 ;
Width:= 125 ;
Height:= 60 ;
Brush.Color:= clBtnFace ;
Parent:= ScrollBox3 ;
Visible:= True ;
end ;
with TEdit.Create(self) do
begin
Name:= 'SzczegolyZadaniaZaliczone' + IntToStr(i+1) ;
Top:= 21 + i*59 ;
Left:= 487 ;
Width:= 119 ;
Color:= clBtnFace ;
Parent:= ScrollBox3 ;
Visible:= True ;
BorderStyle:= bsNone ;
Text:= ListaStopni[NrWybranejOsoby].Zadania[i].Zaliczone ;
Font.Name:= 'Verdana' ;
ShowHint:= True ;
Hint:= 'Potwierdzenie wykonania zadania (osoba potwierdzająca)' ;
Height:= 16 ;
OnExit:= ZadaniaExit ;
OnEnter:= ZadaniaEnter ;
OnKeyPress:= ZadaniaKeyPress ;
end ;
end ;
end ;
procedure TForm1.ZadaniaDodajClick (Sender: TObject) ;
begin
ListaClick (TLabel(self.FindComponent('Lista0'))) ;
end ;
Tablica rekordów, do której się odwołuję wiele razy, wygląda tak (jest uzupełniona z pliku w innej procedurze:
type
TListaZadan = record
Tresc, Data, Zaliczone :string ;
end ;
TStopien = record
Zdobywajacy, Opiekun, Nazwa, DataOtwarcia, DataZamkniecia, Zamkniety :string ;
Zadania :array of TListaZadan ;
end ;
var
Form1: TForm1;
ListaStopni :array of TStopien ;
NrWybranejOsoby :integer ;
Tworzy się tam przycisk (SzczegolyZadaniaDodaj), który na chwilę obecną po kliknięciu jakby odświeża to, usuwa te komponenty i tworzy je jeszcze raz. Problem w tym, że po parokrotnym kliknięciu go (różnie, czasami od razu, czasami za 3-4 razem) wyskakuje błąd "Access violation at address ... in module 'Project1.exe'. Read of address .....".
Błąd ten wyskakuje tylko wtedy, gdy klikam przycisk. Gdy nawet wielokrotnie nacisnę komponent Label, który ma OnClick:= ListaClick ; nic się nie dzieje... I to mnie najbardziej dziwi w tym wszystkim.
Program jest niemal na ukończeniu, miał być gotowy do końca weekendu, ale przez ten błąd zatrzymałem się w miejscu. Bardzo proszę o pomoc - jak to naprawić?