You can do the following...

1.      Instead of using Action  := caFree, use "Release" this will not
raise AV.
2.      To make sure you have single child instance, please use the
following code in your child form

{ Public declarations }

constructor Create(AOwner: TComponent); override;

destructor Destroy; override;

...

 

implementation

 

constructor TForm1.Create(AOwner: TComponent);

begin

  if (Form1 <> nil) then

  begin

    Form1Show;

    Abort;

  end else

      Form1 := inherited Create(AOwner);

end;

 

destructor TForm1.Destroy;

begin

  if (Form1= Self) then    Form1 := nil;

  inherited;

end;

 

Hope this helps,

Kiran Kurapaty

 

________________________________

From: advanced_delphi@yahoogroups.com
[mailto:[EMAIL PROTECTED] On Behalf Of Johan Muller
Sent: 29 June 2007 07:04
To: advanced_delphi@yahoogroups.com
Subject: [advanced_delphi] MDI Applications

 

Hi i'm new to MDI Applications and I have two questions.

 

1. I have a button on my childform to close the form. I know about the
Action := caFree in the onClose event to close the form, but I'm looking
for a way to also close the form when I click on the close button in my
childform. I tried the normal form.close but I get an Access Violation.

 

2. I want to make sure that my users can only open one instance of a
specific childform. In other word some way of checking if the childform
is already open and if it is, it must not open the form again.

 

If anyone can help I will appreciate it very much

Thanks,

JJ.

 


#####################################################################################
Note:

Any views or opinions are solely those of the author and do not necessarily 
represent 
those of Channel Four Television Corporation unless specifically stated. This 
email 
and any files transmitted are confidential and intended solely for the use of 
the 
individual or entity to which they are addressed. If you have received this 
email in 
error, please notify [EMAIL PROTECTED]

Thank You.

Channel 4, 124 Horseferry Road, London, SW1P 2TX. VAT no. GB 626475817
#####################################################################################

Reply via email to