Autor Beitrag
NeoInDerMATRIX
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 245

Win95, Win98(+se), WinNT, Win2000, WinME, WinXP(+pro), VISTA, Linux(SuSe), DOS [MultiMon(3)], Vista
D6 PeE + (FP 2.0l) + D3 Pe + D2005+ D2006 Arch
BeitragVerfasst: Fr 18.02.05 13:31 
Hallo,

mein Problem ist, das ich zur Laufzeit Forms dynamisch erzeuge. Nun möchte ich diese wenn der benutzer oder das Programm dieses nicht mehr braucht schließen. Nun hat die VCL diese blöde eigenschaft, Forms nur auf unsichtbar zu setzen anstat sie wieder frei zu geben. Ich weis das es die möglichkeit gibt das im onClose event zu ändern. Nun ist es aber so das ich das onClose event für etwas anderes brauche. Also ist meine Frage nun kann ich ein Fenster komplett freigeben ohne auf onClose zurückgreifen zu müssen?

Cu
Neo
KidPaddle
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 351

WinXP,Linux
D7 Prof, XE7
BeitragVerfasst: Fr 18.02.05 13:47 
Das FormClose - Event abfragen und Action auf caFree setzten.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TTemplateForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action := caFree;
end;


Gruß
KidPaddle
HariboHunter
ontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 49

Win Xp pro
Delphi 7 pro
BeitragVerfasst: Fr 18.02.05 13:49 
Emmm ja das wollte ich auch gerade sagen, aber der über mir war schneller. :(

_________________
Viel von Nix, ist auch nix!
NeoInDerMATRIX Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 245

Win95, Win98(+se), WinNT, Win2000, WinME, WinXP(+pro), VISTA, Linux(SuSe), DOS [MultiMon(3)], Vista
D6 PeE + (FP 2.0l) + D3 Pe + D2005+ D2006 Arch
BeitragVerfasst: Fr 18.02.05 13:52 
Hallo KidPaddle,

danke für die antwort, aber ich möchte kein Event benutzen. Da ich das für eine art Form Verwaltung benötige.
Aus diesem grund kann ich auch kein Event nutzen, da ich sonst evtl. einen überschreiben würde!
Gibt es keine andere möglichkeit ne Form komplett zu entfernen! Ohne die Events zu nutzen?

Cu
Neo
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Fr 18.02.05 13:56 
Wie schließt du die Form denn?
Gibt es irgendwo in deinem Source eine Stelle, wo du schreibst:
ausblenden Delphi-Quelltext
1:
Form1.Close;					


Falls das so ist, kannst du danach auch noch:
ausblenden Delphi-Quelltext
1:
Form1.Free;					

schreiben.
NeoInDerMATRIX Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 245

Win95, Win98(+se), WinNT, Win2000, WinME, WinXP(+pro), VISTA, Linux(SuSe), DOS [MultiMon(3)], Vista
D6 PeE + (FP 2.0l) + D3 Pe + D2005+ D2006 Arch
BeitragVerfasst: Fr 18.02.05 14:03 
Hi Jasocul,

in der Regel werden die Forms per Klick auf dem netten X oben geschlossen. Das andere habe ich jetzt alles auf Free gestellt. Nur wenn das X geklickt wird wird die Form von der VCL nur versteckt. Und da dadurch das Form ja nicht freigegeben wird.
Zur zeit mache ich das so das sobald eine Form Dynamisch erzeugt wird, ihr onClose ereignis überschireben wird. Damit beim schließen der Form in der onClose functioon der parameter caFree gesetzt werden kann. Nun leider kann ich nun in keiner Form mehr den onClose Eent mehr nutzen. Und das ist mein Problem, und darum suche ich eine andere möglichkeit das Form komplett frei zu geben.

Thx & Cu
Neo
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Fr 18.02.05 14:09 
Ich würde in der Form die Methode DoClose überschreiben und Action auf caFree setzen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
type
  TxyzForm = class(TForm)
  protected
    procedure DoClose(var Action: TCloseAction); override;
  end;


procedure TxyzForm.DoClose(var Action: TCloseAction);
begin
  Action := caFree;
  inherited;
end;


Dadurch wird ganz normal das Event ausgelöst und sofern Action im OnClose-Event nicht geändert wird, wird die Form freigegeben.

Gruß, Motzi

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
NeoInDerMATRIX Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 245

Win95, Win98(+se), WinNT, Win2000, WinME, WinXP(+pro), VISTA, Linux(SuSe), DOS [MultiMon(3)], Vista
D6 PeE + (FP 2.0l) + D3 Pe + D2005+ D2006 Arch
BeitragVerfasst: Fr 18.02.05 14:11 
OK,

das probiere ich mal kurtz, melde mich dann noch mal!

Cu
Neo
NeoInDerMATRIX Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 245

Win95, Win98(+se), WinNT, Win2000, WinME, WinXP(+pro), VISTA, Linux(SuSe), DOS [MultiMon(3)], Vista
D6 PeE + (FP 2.0l) + D3 Pe + D2005+ D2006 Arch
BeitragVerfasst: Fr 18.02.05 14:15 
Hallo,

also ich habe es nun folgender Massen gemacht.
Habe ne neue Klasse tMyForm definiert, und in dieser die DoClose Function überschrieben.
Damit spare ich mir das immer wieder in jeder Form zu überschreiben.

Danke dir Motzi für den Tip.

Thx & Cu
Neo
KidPaddle
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 351

WinXP,Linux
D7 Prof, XE7
BeitragVerfasst: Fr 18.02.05 14:16 
Es gibt dann nur noch die Alternative, ein von TForm abgeleitetes Objekt zu verwenden, welches die DoClose - Methode überschreibt. Diese ruft das Event FormClose auf. Das ueberschreiben könnte wie folgt gehen.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
type
  TAutoFreeForm = class(TForm)
  protected
    procedure DoClose(var Action: TCloseAction); override;    
  end;

procedure TAutoFreeForm.DoClose(var Action: TCloseAction); 
begin
  Action := caFree;
  inherited DoClose(Action);
end;


Intern setzt Delphi beim Aufruf von DoClose auf caHide und dieses Verhalten wird dadurch geändert. Verwenden kannst Du es wie ein normales Formular, Du must nur das TForm durch dein neunes Objekt austauschen.

Gruß
KidPaddle

EDIT:
Tja, Motzi war schneller.
KidPaddle
NeoInDerMATRIX Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 245

Win95, Win98(+se), WinNT, Win2000, WinME, WinXP(+pro), VISTA, Linux(SuSe), DOS [MultiMon(3)], Vista
D6 PeE + (FP 2.0l) + D3 Pe + D2005+ D2006 Arch
BeitragVerfasst: Fr 18.02.05 14:17 
HI KidPaddle,

Jep, auf die idee bin ich auch gekommen, danke dir.

Cu
Neo