Autor Beitrag
SteheAufDerLeitung
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 104



BeitragVerfasst: Fr 18.01.08 14:52 
Hallo!

Ich habe ein Prog mit Dialogfenstern. In einer try-except-Anweisung soll das Prog ggf abgebrochen werden:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
try
  ...Abfrage geht schief..
except
  ShowMessage('S ging schief! Ende der Fahnenstange!');
  MainForm.Close;
end;


Die Message wird gezeigt, doch das Prog wird nicht beendet - sondern eine Warnung kommt: "Unbekannter Fehler!"??

Könnt ihr mir weiterhelfen?

Besten Dank
Escalade
ontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 18

Win 95 Only
Pascal only
BeitragVerfasst: Fr 18.01.08 14:56 
Titel: Finally
Finally
Form1.Close
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8548
Erhaltene Danke: 477

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Fr 18.01.08 15:01 
Bei mir funktioniert so ein Konstrukt. An welcher Stelle im Programm hast du denn diesen Code? Im FormCreate oder FormShow dürfte das nicht funktionieren, ansonsten schon.

Das mit finally ist Quatsch - es sei denn du willst, dass die Form auf jeden Fall geschlossen wird ;-).

_________________
We are, we were and will not be.
Regan
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2157
Erhaltene Danke: 72


Java (Eclipse), Python (Sublimetext 3)
BeitragVerfasst: Fr 18.01.08 15:01 
user profile iconEscalade hat folgendes geschrieben:
Finally
Form1.Close

user profile iconSteheAufDerLeitung hat folgendes geschrieben:
try-except-Anweisung


Ich würde es mit Application.Termintate mal probieren.
SteheAufDerLeitung Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 104



BeitragVerfasst: Fr 18.01.08 15:10 
Danke für die schnellen Antworten!!

Die Anwendung steht in MainForm.Activate - sollte aber trotzdem irgendwie gehen!

Application.Terminate funzt leider auch nicht :-/

Kann ich denn das Finally in den Except-Teil schreiben? Wenn die Abfrage schief läuft, dann soll das Prog immer beendet werden..


Schöne Grüße
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8548
Erhaltene Danke: 477

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Fr 18.01.08 15:14 
Im FormActivate sollte das auch nicht gehen. Überleg mal...du steigst in dein Auto ein und gleichzeitig wieder aus. Das geht nicht.

Quick&Dirty könntest du anstatt von Close einen Timer starten, der dann die Form schließt, oder mit Halt wirklich Gewalt anwenden.

_________________
We are, we were and will not be.
SteheAufDerLeitung Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 104



BeitragVerfasst: Fr 18.01.08 15:38 
Komisch..

Hab das MainForm.Close mal rausgelöscht und genau dasselbe wieder reingeschrieben - jetzt funktionierts!?!?

Ich lass den Thread noch offen, falls ich noch was rausfinde..

Gruß und schönes Wochenende!
Jann1k
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 866
Erhaltene Danke: 43

Win 7
TurboDelphi, Visual Studio 2010
BeitragVerfasst: Fr 18.01.08 16:27 
könnte es sein, dass du das ganze getestet hast, als du gerade am programmieren warst? Wenn ja, zeigt Delphi dir dennoch die Fehlermeldungen an. Als es geklappt hat, hast du das Programm "so" gestartet (also nur die exe) oder?