Autor Beitrag
landwehr
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 46

WIN XP, WIN 7, WIN 8
Delphi 6, Delphi 2007, Delphi XE2
BeitragVerfasst: Mi 13.03.13 20:35 
Hallo,

ich habe eine Form indem ich mit einem Button ein weiteres Form aufrufe. Beide fsMDIChild. Nun Verlasse ich das zweite Formular und habe beim OnClose Ereignis folgenden Code:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TKontoSuchenFrm.FormClose(Sender: TObject; var Action: TCloseAction); 
begin 
SucheKontoQry.Close; 
SucheKontoSrc.DataSet := NIL
if ProgOptions.Common.WindowPosition then 
ToolsForm.SaveWindowPosition(Self); 
Action := caFree; 
TForm(Self) := nil
end;


Frage ich dann im ersten Formular ab ob das zeite nil ist, ist es nicht nil warum nicht?

Hat jemand eine Idee, bin schon am verzweifeln.

Walter

Moderiert von user profile iconMartok: Delphi-Tags hinzugefügt


Zuletzt bearbeitet von landwehr am Do 14.03.13 12:03, insgesamt 1-mal bearbeitet
WasWeißDennIch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 653
Erhaltene Danke: 160



BeitragVerfasst: Mi 13.03.13 21:06 
Das dürfte nicht die Referenz sein, die Du eigentlich auf nil setzen willst. Wenn Du so etwas unbedingt brauchst, könntest Du das über ein Event lösen.
Tranx
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 648
Erhaltene Danke: 85

WIN 2000, WIN XP
D5 Prof
BeitragVerfasst: Do 14.03.13 17:39 
Hast Du mal mit dem Debugger getestet, ob die Formclose-Prozedur aufgerufen wird? Wenn ja, dann gib doch mal als überwachte Variable das zu schließende Formular an. Und was erscheint denn als Ergebnis bei der Abfrage im ersten Formular?

_________________
Toleranz ist eine Grundvoraussetzung für das Leben.
WasWeißDennIch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 653
Erhaltene Danke: 160



BeitragVerfasst: Do 14.03.13 18:42 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
procedure TForm1.Button1Click(Sender: TObject);
var
  Ref1, Ref2: TForm;
begin
  Ref1 := TForm.Create(nil);
  try
    Ref2 := Ref1;
  finally
    Ref1.Free;
    Ref1 := nil;
  end;
  if Ref1 = nil then
    ShowMessage('Erste Referenz ist weg')
  else
    ShowMessage('Oops, ein wilder Zeiger: Ref1');
  if Ref2 = nil then
    ShowMessage('Zweite Referenz ist auch weg')
  else
    ShowMessage('Oops, ein wilder Zeiger: Ref2');
end;

Preisfrage: welche Meldungen erscheinen?