Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems closing MDI form

Status
Not open for further replies.

BasSchouten

IS-IT--Management
Jul 31, 2001
33
NL
In my application an MDI form is opened (child) with the following code:
Code:
Form_Faktuur = TForm_Faktuur.Create(Application);

The OnClose event of the form contains:
Code:
procedure TForm_Faktuur.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  Action := caFree;
end;

Somewhere else in the application i want to check if the form exists, and if so, close it. I'v tried the following:

Code:
  if Form_Faktuur <> nil then
     if Form_Faktuur.Visible then
        Form_Faktuur.Close;

but i get an access violation when the second if statement executes ... I thought that freeing the form would set the form variable to NIL .. but apparently it doenst.

anyboy got any idea what i'm doing wrong??
Bas Schouten
System Development & Webdesign
CBIS BV Holland
logo.gif

 
Hi,
about your MDI child form closing problem, you don't need to test if it is visible. Provided your 'Faktuur' child form is not nil it is existing and you thus only need to close it by calling the 'close' method of the form.
ok?
cheers,
BonnScott
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top