Autor Beitrag
eternity
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32



BeitragVerfasst: So 27.06.04 22:45 
Moin Delphianer !

Hab nen klitze kleines Problem.
Und zwar geht es um die Dynamische Erstellung eines Formulars - Ich weiß das Thema gibt es schon zu genüge - Aber nicht meins.

Bsp.

Ich habe zwei Formulare. Davon ist Form2 verfügbar - also noch nicht geladen.

Ich kann Form2 anhand von...

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
var
  a:TForm;
begin
  a:=TForm2.Create(self);
  a.Show;
end;


...clonen.

Wie kann ich jetzt aber Form2 anhand einer übergabevariable clonen ?

Bsp. - Dieses ist nicht funktionabel ! - Soll nur nen denkanstoß sein.


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure GoToForm(a:TForm); // <-- Wird aufgerufen z.B. GoToForm(Form2);
var
  b:TForm;
begin
  b:=a.Create(self); //<-- führt zur einer Fehlermeldung
  b.Show;
end;


Kann mir jemand einen Tip geben, wie ich das oder ähnlich funktionabel bekomme !!!


MfG

Moderiert von user profile iconMotzi: Delphi-Tags hinzugefügt.
maxk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1696
Erhaltene Danke: 1

Win XP, Debian Lenny
Delphi 6 Personal
BeitragVerfasst: So 27.06.04 22:51 
Nicht getestet!
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure GoToForm(a:TForm); // <-- Wird aufgerufen z.B. GoToForm(Form2); 
var 
b:TForm; 
begin 

b:=TForm( a.Create(self) );
b.Show;
Bitte verwende in Zukunft die [ delphi ]-Tags!

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: So 27.06.04 22:56 
Geht folgendermaßen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
type
  TFormClass = class of TForm;

procedure GoToForm(a: TFormClass);
var
  b:TForm;
begin
  b := a.Create(self);
  b.Show;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  GoToForm(TForm2);
end;

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!


Zuletzt bearbeitet von Motzi am So 27.06.04 23:37, insgesamt 1-mal bearbeitet
eternity Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32



BeitragVerfasst: So 27.06.04 23:30 
Vielen Dank für die Ultra schnelle Antwort !

Der Zusatz von Motzi hat mir weitergeholfen.

:autsch: Auf das hätte ich auch noch selbst kommen können ;-)


THX