Autor Beitrag
Stread
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 188

Win 7
Delphi XE
BeitragVerfasst: Do 03.09.09 18:17 
ich habe 2 Formen. Das Programm startet mit der 1. Form. Ein Button soll beim draufklicken diese Form schließen und die 2.Form öffnen. Wenn ich das Programm oben über das Rote X schließe sollen sich alle Formen schließen.
Mein Problem: Entweder schließt sich Form 1 nicht wenn ich in Form 2 bin oder das Programm beendet sich bevor Form 2 kommt.
Was ich habe: Über Form2.Show die 2. Form eingeblendet. Nun möchte ich die 1. Form schließen. Bei Form1.Close schließt sich alles und über .Visible lässt es sich garnicht mehr schließen.

Danke

Stread


Moderiert von user profile iconNarses: Topic aus Delphi Language (Object-Pascal) / CLX verschoben am Do 03.09.2009 um 19:18


Zuletzt bearbeitet von Stread am Do 03.09.09 20:10, insgesamt 1-mal bearbeitet
Andreas L.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1703
Erhaltene Danke: 25

Windows Vista / Windows 10
Delphi 2009 Pro (JVCL, DragDrop, rmKlever, ICS, EmbeddedWB, DEC, Indy)
BeitragVerfasst: Do 03.09.09 18:25 
Wenn du das Hauptformular (Form1) schließt, wird die Anwendung beendet. Verwende einfach .Hide anstatt .Close um das erste Formular auszublenden.
Stread Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 188

Win 7
Delphi XE
BeitragVerfasst: Do 03.09.09 18:31 
Wenn ich das Programm nun aber in der 2. Form schließe ist es immer noch nicht beendet. Es läuft anscheinend Form1 im Hintergrund weiter. Kann ich Form 1 ganz schließen wenn ich zu Form2 wechsle?
DeddyH
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Do 03.09.09 18:32 
Nein, das wurde doch bereits gesagt. Schließe doch einfach im OnClose von Form2 Form1 gleich mit.
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Do 03.09.09 18:35 
Wird Form1 ausschließlich beim Start gebraucht? Gegebenfalls macht es Sinn Form2 als Hauptformular zu definieren. Ich möchte hier an dieser Stelle noch das Stichwort Suche in der Entwickler-Ecke SPLASHSCREEN in die Runde werfen.

Grüße,
Marc.

edit: Post korrigiert und Satz wieder eingefügt, damit nachfolgender Post von user profile iconDeddyH weiterhin Sinn ergibt.


Zuletzt bearbeitet von Marc. am Do 03.09.09 18:39, insgesamt 2-mal bearbeitet
DeddyH
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Do 03.09.09 18:37 
Trotz der falschen Schreibweise 3 Treffer? :shock:
René R.Fo.
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 116

Win7
Delphi5 Delphi2005
BeitragVerfasst: Do 03.09.09 18:38 
Der Cood:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure TForm1.Button1Click(Sender: TObject);
begin
     Form1.Visible := False;
     Form2.Visible := True;
end;
{...}
procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
     Form1.Close;
end;

_________________
If Promille or Cannabis.Volumen > IQ then
dec(Gehirnzellen.Anzahl);
DeddyH
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Do 03.09.09 18:42 
Oder auch:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure TForm1.Button1Click(Sender: TObject);
begin
  Visible := False;
  Form2.Show;
end;
{...}
procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Application.MainForm.Close;
end;
Stread Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 188

Win 7
Delphi XE
BeitragVerfasst: Do 03.09.09 18:48 
Danke euch.

Ich habe nun im OnClose Ereignis von Form2 Form1 auch geschlossen.
Stread Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 188

Win 7
Delphi XE
BeitragVerfasst: Do 03.09.09 20:12 
Wenn ich das nun mit .Hide mache wird das Erste Fenster (Form1) noch normal in der Taskleiste und im Task-Manager angezeigt. Sobald ich aber zur 2. Form wechsle ist beides weg. Wie kann man das umgehen?
René R.Fo.
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 116

Win7
Delphi5 Delphi2005
BeitragVerfasst: So 13.09.09 13:16 
user profile iconStread hat folgendes geschrieben Zum zitierten Posting springen:
Wenn ich das nun mit .Hide mache wird das Erste Fenster (Form1) noch normal in der Taskleiste und im Task-Manager angezeigt. Sobald ich aber zur 2. Form wechsle ist beides weg. Wie kann man das umgehen?

Dan mach es doch so:
user profile iconRené R.Fo. hat folgendes geschrieben Zum zitierten Posting springen:
Der Cood:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure TForm1.Button1Click(Sender: TObject);
begin
     Form1.Visible := False;
     Form2.Visible := True;
end;
{...}
procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
     Form1.Close;
end;

_________________
If Promille or Cannabis.Volumen > IQ then
dec(Gehirnzellen.Anzahl);