Delphi-PRAXiS
Seite 2 von 3     12 3      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi TForm1.FormCreate -> Form2.Show; (https://www.delphipraxis.net/27516-tform1-formcreate-form2-show%3B.html)

bttb930 11. Aug 2004 14:40

Re: TForm1.FormCreate -> Form2.Show;
 
Vertausch doch einfach die Application.CreateForm-Befehle, so dass zuerst Form2 erstellt wird und dann Form1.

Dann wird auch automatisch Form2 beim Programmstart angezeigt.

Allerdings wird das Programm auch beendet wenn Form2 geschlossen wird.

lume96 11. Aug 2004 14:46

Re: TForm1.FormCreate -> Form2.Show;
 
Oder
Delphi-Quellcode:
Application.CreateForm(Tform2, Form2);
aus der projektdatei rausnehmen und

Delphi-Quellcode:
procedure TForm1.FormCreate(Sender: TObject);
begin
   Form2 := TForm2.Create(self);
   Form2.Show;

end;
benutzen.

Sollte eigentlich auch funktionieren.

SleepyMaster 11. Aug 2004 15:11

Re: TForm1.FormCreate -> Form2.Show;
 
Oder

Delphi-Quellcode:
procedure TForm2.FormCreate(Sender: TObject);
begin
  Show;
end;

StanY 11. Aug 2004 20:07

Re: TForm1.FormCreate -> Form2.Show;
 
Vielen dank für die schnelle und kompetente Hilfe. Ich denke die letzte Möglichkeit werde ich verwenden, da es so sein soll, dass das Programm halt nur beendet werden soll, wenn Form1 beendet werden soll.

Ansonsten, also, wenn das nicht geht, werde cih wohl auf die timer zurückgreifen.

Danke.

edit: @SleepyMaster: Tut mir leid, dich habe ich ganz übersehen :/.

Also, da mit die Timer-Variante doch nicht mehr gefällt. Deins geht auch nicht. Dieselbe Fehlermeldung:



Delphi-Quellcode:
procedure TfrmMain.FormShow(Sender: TObject);
begin
  frmObjTreeView.Show;
end;
Fehler:
Project mdc.exe raised exception class EAccsessViolation with Message 'Access violation at address 00445BEA in module 'mdc.exe'. Read of address 000002F4'. Process stopped. Use Step or Run to continue.
|OK| |HELP|

Aenogym 11. Aug 2004 21:46

Re: TForm1.FormCreate -> Form2.Show;
 
Zitat:

Zitat von SleepyMaster
Oder

Delphi-Quellcode:
procedure TForm2.FormCreate(Sender: TObject);
begin
  Show;
end;

das geht problemlos...

Aenogym

StanY 11. Aug 2004 21:51

Re: TForm1.FormCreate -> Form2.Show;
 
Aber wie mache ich es, dass die anderen Formen/Forms auch erstellt werden, wenn ich frmMain erstelle, also, das Programm starte?

Einafch nur in Form2.FormCrate das reinschreiben geht nämlich net :/.

StanY 13. Aug 2004 13:01

Re: TForm1.FormCreate -> Form2.Show;
 
Weiß niemand eine Antwort *sry wegen des Doppelposts* :/

teebee 13. Aug 2004 13:37

Re: TForm1.FormCreate -> Form2.Show;
 
Zitat:

Zitat von StanY
Aber wie mache ich es, dass die anderen Formen/Forms auch erstellt werden, wenn ich frmMain erstelle, also, das Programm starte?

Das kannst Du in den Projektoptionen einstellen, per Default werden aber alle Forms beim Programmstart erzeugt.
Wenn Du sie auch noch alle anzeigen willst, rufe das entsprechende FormX.Show in der Projektdatei nach dem CreateForm auf.

Gruß, teebee

lume96 13. Aug 2004 13:48

Re: TForm1.FormCreate -> Form2.Show;
 
Hi,

Zitat:

Zitat von StanY
Aber wie mache ich es, dass die anderen Formen/Forms auch erstellt werden, wenn ich frmMain erstelle, also, das Programm starte?

Einafch nur in Form2.FormCrate das reinschreiben geht nämlich net :/.

Zwei Möglichkeiten :
1) über das Menü Projekt/Optionen (frei aus dem Französischen übersetzt, hab keine deutsche Delphi-Version)

2) Manuell in der Projektdatei : (anzeigen durch Menü Projekt/Source anzeigen (wieder frei aus dem Französischen)). Die Projektdatei könnte dann wie folgt aussehen :

Delphi-Quellcode:
program test;

uses
  Forms,
  main in 'main.pas' {Form1},
  Unit2 in 'Unit2.pas' {Form2};

{$R *.RES}

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.CreateForm(TForm2, Form2);
  Application.Run;
end.
Wie man sehen kann, werden zuerst die Forms erstellt, dann Application.Run aufgerufen.

Der Form.Show event des MainForms wird erst nach Application.Run aufgerufen, und zu dem Zeitpunkt ist Form2 schon erstellt.

Somit sollte bei einem :
Delphi-Quellcode:
procedure TForm1.FormShow(Sender: TObject);
begin

   Form2.Show;

end;
auch keine AccessViolation mehr auftreten. Die tritt nämlich 'nur' auf, wenn Du Form2.Show aufrufst, bevor der Form2 estellt wurde.

Hab das bei mir (Delphi 7 Pro) noch mal kurz getestet und es funktioniert einwandfrei.

MfG,
Lutz

StanY 13. Aug 2004 14:25

Re: TForm1.FormCreate -> Form2.Show;
 
Vielen Dank. Funktioniert Einwandfrei :).


Alle Zeitangaben in WEZ +1. Es ist jetzt 12:48 Uhr.
Seite 2 von 3     12 3      

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz