Thema: Delphi FindComponent Frage

Einzelnen Beitrag anzeigen

Udo

Registriert seit: 19. Jan 2003
54 Beiträge
 
Delphi 8 Architect
 
#9
  Alt 23. Jan 2003, 22:56
tf:= Application.FindComponent('test') as TForm2; So was ist schlecht. Wenn etwas gefunden wird was test heisst aber nicht vom Type TForm ist fliegt die das um die Ohren.
Besser:
Delphi-Quellcode:
var C: TComponent;
begin
   C:= TForm(Application.FindComponent('test'));
   if C = nil then
   begin
     Application.CreateForm(TForm, Form2);
     Form2.Name:= 'test';
     Form2.Show;
   end
   else
     if C is TForm then
       with C as TForm do Height:= 300;
end;
  Mit Zitat antworten Zitat