Autor Beitrag
Jonathanubx
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 32



BeitragVerfasst: Fr 14.03.08 15:42 
hallo,
ich hab ein relativ einfaches Problem (zumindest hat es am anfang den anschein gehabt):
ich möchte, dass eine if-anweisung ausgeführt wird sobald das programm beendet wird.
sei es durch das herunterfahren des rechners oder durch manuelles beenden.
beim stöbern bin ich auf OnCloseQuery gestoßen, weiß aber leider nicht wo das im code zu finden sein soll oder welche proceduren ich definieren muss oder was auch immer.
könnt ihr mir helfen?

danke schon mal^^


Moderiert von user profile iconGausi: Topic aus Delphi Language (Object-Pascal) / CLX verschoben am Fr 14.03.2008 um 19:52
Agawain
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 460

win xp
D5, MySQL, devxpress
BeitragVerfasst: Fr 14.03.08 15:44 
Hi

onclosequery ist ein Ereignis von TForm.

_________________
Gruß Aga
Jonathanubx Threadstarter
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 32



BeitragVerfasst: Fr 14.03.08 15:46 
und das sagt mir was? wie kann ich es verwenden? ein code bsp wäre nett
nw90
Hält's aus hier
Beiträge: 9



BeitragVerfasst: Fr 14.03.08 15:49 
Ich glaube es reicht schon, wenn du das Ereignis 'OnClose' benutzt und da dann deine if- Schleife reinbrngst:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
 //Hier dann deine If-Schleife
end;


Ich hoffe, dass es das war, was du meintest ;)

Mfg
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Fr 14.03.08 15:52 
Zitat:
ausblenden Delphi-Quelltext
1:
 //Hier dann deine If-Schleife					

Es gibt keine If-Schleife :mahn:

_________________
Markus Kinzler.
nw90
Hält's aus hier
Beiträge: 9



BeitragVerfasst: Fr 14.03.08 15:53 
user profile iconmkinzler hat folgendes geschrieben:
Zitat:
ausblenden Delphi-Quelltext
1:
 //Hier dann deine If-Schleife					

Es gibt keine If-Schleife :mahn:


Dann eben die If-Anweisung :)
Jonathanubx Threadstarter
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 32



BeitragVerfasst: Fr 14.03.08 18:33 
okay hab ich versucht. ich hab euch jetzt mal den code der gesamten unit gepostet, denn ich befürchte iwo fehlt noch was.
ich habe hier meine spätere if-anweisung durch ein vorläufiges ShowMessage ersetzt.
vlt seht ihr woran es liegen könnte:


ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;

type
  TForm1 = class(TForm)
  procedure FormClose(Sender: TObject; var Action: TCloseAction);

  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation
{$R *.dfm}

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  ShowMessage('test');
end;


end.
nw90
Hält's aus hier
Beiträge: 9



BeitragVerfasst: Fr 14.03.08 19:42 
Was genau ist denn jetzt noch dein Problem? Wenn ich die Anwendung schließe, kommt bei mir der Text.
Jonathanubx Threadstarter
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 32



BeitragVerfasst: Fr 14.03.08 21:06 
ja genau das sollte eigentlich passieren ...
bei mir allerdings nicht, da schließt sich die form einfach ...
ich weiß nicht ob das vlt an delphi 7 liegen kann ?!
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: Fr 14.03.08 21:10 
Hi,

Du musst im Object Inspector des Design-Teils unter Events den Namen der Prozedur bei onClose einfügen.

mfG,

_________________
Centaur spears can block many spells, but no one tries to block if they see that the spell is a certain shade of green. For this purpose it is useful to know some green stunning hexes. (HPMoR)
Agawain
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 460

win xp
D5, MySQL, devxpress
BeitragVerfasst: Fr 14.03.08 21:37 
Kann sein, nimm lieber onCloseQuery.

Hab auch die Erfahrung machen müssen (Delphi5), dass während OnClose noch ausgeführt wird, Delphi trotzdem schon anfängt, die Anwendung abzubauen.

_________________
Gruß Aga
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: Fr 14.03.08 22:09 
Hi,

@ user profile iconAgawain Ich bin mir noch nicht ganz sicher, ob er die Methode auch dem onClose-Ereignis zugewiesen hat.

mfG,

_________________
Centaur spears can block many spells, but no one tries to block if they see that the spell is a certain shade of green. For this purpose it is useful to know some green stunning hexes. (HPMoR)


Zuletzt bearbeitet von Hidden am Sa 22.08.09 09:54, insgesamt 1-mal bearbeitet
Saarpoint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 199

Win XP Home, Vista Home Premium
D5 Std, D7 pers., D2005 Pro. SP3, TurboDelphi
BeitragVerfasst: Sa 15.03.08 00:02 
Das Problem hatte ich auch mal. Es liegt eigentlich an der richtigen Positionierung des "CanClose"-Befehls...
Standardmäßig ist dieser auf True. Versuch mal so was wie

ausblenden Delphi-Quelltext
1:
2:
3:
CanClose := false;
 ShowMessage('Test');
CanClose := true;


Kann aber nicht garantieren, ob das funtzt, nicht getestet...

Andreas

_________________
Standart := false; Standard := true;
Jonathanubx Threadstarter
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 32



BeitragVerfasst: Sa 15.03.08 08:26 
ja danke, funktioniert einwandfrei.

habs so versucht (mit checkbox bzw. onclosequery):
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm1.FormClose(Sender: TObject; var CanClose: Boolean);
begin
  If CheckBox1.Checked = true then
  begin
  CanClose := False;
  ShowMessage('Kann nicht geschlossen werden!');
  end
  else CanClose := True;
end;
Saarpoint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 199

Win XP Home, Vista Home Premium
D5 Std, D7 pers., D2005 Pro. SP3, TurboDelphi
BeitragVerfasst: Sa 15.03.08 15:47 
Super, dann bin ich ja froh, dass ich helfen konnte.
Übrigens: Es gibt auch eine IF-Schleife! Man nennt sie nur Until... :rofl: :zwinker:

Andreas

_________________
Standart := false; Standard := true;
oneP
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 71

Win XP Professional
Turbo Delphi 2006
BeitragVerfasst: Fr 21.08.09 20:05 
Hallo! ich misch mich mal ein...

ich habe auch dieses Problem dass mir beim Beenden, das was in OnClose steht nicht ausgeführt wird.
in meinem Fall ist es keine If-anweisung, sondern eine Procedur. (müsste doch an sich egal sein...)

Doch diese Procedur will nicht laufen. Im OnClose als auch im OnCloseQuery.
Auch mit canclose := false / canclose := true

Diese procedur soll einfach nur nachfragen ob die Änderungen gespeichert werden sollen.

Vielleicht könnt ihr mir auch helfen.....
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Fr 21.08.09 20:19 
Was in den Ereignissen passiert, ist im Prinzip egal. Wobei OnClose natürlich nur aufgerufen wird, wenn das formular geschlossen wird, also CanClose auf True bleibt.
Klingt im Moment so, als wäre das Ereignis nicht dem Formular zugewiesen.


Aber: Mach bitte nen neuen Thread auf - der hier ist schon über ein Jahr alt.

_________________
PROGRAMMER: A device for converting coffee into software.
oneP
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 71

Win XP Professional
Turbo Delphi 2006
BeitragVerfasst: Fr 21.08.09 20:34 
nicht mehr nötig..

hat sich erledigt. Hab den Fehler nach langer Suche in der Prozedur gefunden. :D