Autor Beitrag
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Fr 01.04.05 21:37 
Moin... ;)

Delphi bringt mir bei der Function einen Fehler.
ausblenden Quelltext
1:
[Error] Unit1.pas(40): Undeclared identifier: 'FindComponent'					

Bei der Procedure jedoch nicht... :shock:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
function ClearBackground: Boolean;
begin
with TImage(FindComponent('BkgrndImage')) do
begin
Free;
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
with TImage(FindComponent('BkgrndImage')) do
begin
Free;
end;
end;

Ich versteh's nicht... :(
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: Fr 01.04.05 21:51 
FindComponent ist eine Methode von TControl.

_________________
Ciao, Sprint.
WeBsPaCe Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Fr 01.04.05 21:51 
Es geht sogar so nicht:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
procedure ClearBackground;
begin
with TImage(FindComponent('BkgrndImage')) do
begin
Free;
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
with TImage(FindComponent('BkgrndImage')) do
begin
Free;
end;
end;

Jetzt ist doch nur noch der Name der procedure anders oder?? Komisch... Bin am verzweifeln... :(
WeBsPaCe Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Fr 01.04.05 21:52 
user profile iconSprint hat folgendes geschrieben:
FindComponent ist eine Methode von TControl.

Heißt was?? :gruebel:
der_zaehe
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 317

WinXP SP2
D6 Pers, D2005 Prof, VS2005
BeitragVerfasst: Fr 01.04.05 21:52 
habs bei mir grad getestet und es ging einwandfrei.
vielleicht solltest du mal self davorschreiben und gucken obs dann geht
oder deine uses-klausel überprüfen
aber sonst ist mir echt unklar woran das liegt

_________________
[inspirationslos]
demo88
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 160

Ubuntu 6.04, Win XP
Delphi 7
BeitragVerfasst: Fr 01.04.05 21:54 
Also egentlich ist es klar woran es liegt:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
function ClearBackground: Boolean;   
begin   
with TImage(form1.FindComponent('BkgrndImage')) do   
begin   
Free;   
end;   
end;   

procedure TForm1.Button1Click(Sender: TObject);   
begin   
with TImage(FindComponent('BkgrndImage')) do   
begin   
Free;   
end;   
end;
WeBsPaCe Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Fr 01.04.05 21:54 
user profile iconder_zaehe hat folgendes geschrieben:
vielleicht solltest du mal self davorschreiben und gucken obs dann geht

Wo davor?? :lol:
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: Fr 01.04.05 21:56 
user profile iconWeBsPaCe hat folgendes geschrieben:
user profile iconSprint hat folgendes geschrieben:
FindComponent ist eine Methode von TControl.

Heißt was?

In deinen Beispielen rufst du FindComponent so auf, als wäre es eine globale Funktion. Das ist es aber nicht.

_________________
Ciao, Sprint.
WeBsPaCe Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Fr 01.04.05 21:56 
user profile icondemo88 hat folgendes geschrieben:
Also egentlich ist es klar woran es liegt:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
function ClearBackground: Boolean;   
begin   
with TImage(form1.FindComponent('BkgrndImage')) do   
begin   
Free;   
end;   
end;   

procedure TForm1.Button1Click(Sender: TObject);   
begin   
with TImage(FindComponent('BkgrndImage')) do   
begin   
Free;   
end;   
end;

Stimmt. So geht's. Kann ich das jetzt irgendwie so machen, dass es unabhängig von dem Namen des Formulars geht?? :gruebel:
der_zaehe
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 317

WinXP SP2
D6 Pers, D2005 Prof, VS2005
BeitragVerfasst: Fr 01.04.05 22:06 
wozu?
ein image liegt doch immer nur auf einem form, oder? :gruebel:

_________________
[inspirationslos]
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: Fr 01.04.05 22:06 
Komponenten haben die Eigenschaft Owner. Das z.B. auch bei Create angegeben wird.
Bei MeinImage := TImage.Create(nil) wird Form1.FindComponent nichts finden. Weil Owner nicht gesetzt ist.

_________________
Ciao, Sprint.
WeBsPaCe Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Fr 01.04.05 22:20 
Ich hab das Problem jetzt so gelöst:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure ClearBackground(aForm: String);
begin
with TForm(Application.FindComponent(aForm)) do
with TImage(FindComponent('BkgrndImage')) do Free;
end;

Ich lass mir einfach den Namen, wo das Image drauf ist per Parameter übergeben. ;)