Autor Beitrag
qwert
Hält's aus hier
Beiträge: 5



BeitragVerfasst: Do 20.04.06 21:56 
Hallo,

wenn ich ein Formular in der OnCreate-Prozedur eines anderen Formulars erzeuge, dann stellt sich immer das falsche Formular in den Vordergrund:
Bsp.:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.FormCreate(Sender: TObject);
begin
  Form2:=TForm.Create(Application);
  Self.Hide;
  Form2.Show;
end;


wobei Form1 mein Hauptformular ist und ich möchte, dass sich Form2 beim Programmstart zur kurzen Dateneingabe zeigt. Vielleicht stellt der geerbte Constructor automatisch Form1 am Schluss in den Vordergrund? Wie kann man das umgehen?

Vielen Dank im Voraus

Moderiert von user profile iconGausi: Delphi-Tags hinzugefügt
Moderiert von user profile iconGausi: Topic aus Sonstiges (Delphi) verschoben am Fr 21.04.2006 um 08:35
Ah-El-Eh-Iks
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 28

Win 3.11, Win ME, Win XP
Delphi 3 Prof., Delphi 2005 Pers.
BeitragVerfasst: Do 20.04.06 23:05 
Hi,

probier mal statt Form2.Show Form2.ShowModal. Dann geht es bei mir, er lädt dann Form1 erst, wenn man Form2 geschlossen hat.

Grüße

Alex

_________________
Ah El Eh Iks = A-L-E-X = ALEX (so heiß ich ;-) )
qwert Threadstarter
Hält's aus hier
Beiträge: 5



BeitragVerfasst: Fr 21.04.06 21:12 
Danke für die Antwort,

Form2 soll aber zur Dateneingabe geeignet sein und dann geht ShowModal irgendwie nicht...
Ich versuche mal was am constructor zu machen.
Blawen
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 616
Erhaltene Danke: 33

Win XP, Vista, 7
Delphi 5 Prof., BDS 2006 Prof. RAD Studio XE
BeitragVerfasst: Fr 21.04.06 22:06 
user profile iconqwert hat folgendes geschrieben:
Form2 soll aber zur Dateneingabe geeignet sein und dann geht ShowModal irgendwie nicht...

Wieso sollst Du in Form2 keine Daten eingeben können?
Einziger Unterschied zwischen Show und Showmodal ist meines Wissens, dass bei Showmodal erst zu Form1 zurückgekehrt werden kann, wenn Form2 geschlossen wird.

_________________
Es kompilert, wir können ausliefern.
Und es kompiliert wieder - das Update ist fertig - bitte 100 Euro ;-)
Ah-El-Eh-Iks
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 28

Win 3.11, Win ME, Win XP
Delphi 3 Prof., Delphi 2005 Pers.
BeitragVerfasst: Sa 22.04.06 05:14 
Also bei mir hat ShowModal auch funktioniert... Oder denkt ihr, ich schreibe was, ohne es ausprobiert zu haben? :-)
Blawen
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 616
Erhaltene Danke: 33

Win XP, Vista, 7
Delphi 5 Prof., BDS 2006 Prof. RAD Studio XE
BeitragVerfasst: Sa 22.04.06 11:03 
user profile iconAh-El-Eh-Iks hat folgendes geschrieben:
Also bei mir hat ShowModal auch funktioniert... Oder denkt ihr, ich schreibe was, ohne es ausprobiert zu haben? :-)
Wieso ihr? Ich weiss, dass es geht ;-)

_________________
Es kompilert, wir können ausliefern.
Und es kompiliert wieder - das Update ist fertig - bitte 100 Euro ;-)
raiguen
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 374

WIN 2000prof, WIN XP prof
D7EP, MSSQL, ABSDB
BeitragVerfasst: Sa 22.04.06 12:12 
Moin :)
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.FormCreate(Sender: TObject);
begin
  Form2:=TForm.Create(Application);
  Form2.ShowModal;
end;

funktioniert in der Tat nicht einwandfrei :-(
Allerdings das
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.FormCreate(Sender: TObject);
begin
  Application.CreateForm(TForm2,Form2);
  Form2.ShowModal;
  Form2.Free;
end;

auf jeden Fall, sprich: Form2 wird zur Dateneingabe angezeigt und nach dem Schließen kommt dann erst die Form1 zum Vorschein ;-)
Wenn Form2 modal geöffnet werden soll, dann ist im Objektinspektor Visible := False zu setzen.
Ah-El-Eh-Iks
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 28

Win 3.11, Win ME, Win XP
Delphi 3 Prof., Delphi 2005 Pers.
BeitragVerfasst: Sa 22.04.06 16:16 
OK, ich geben zu, dass bei mir das FormCreate in der Projekt-Unit stand.