Set the form variable as a local variable and you won't have that problem since 
the form variable goes out of scope after each instance creation. You can 
destroy it in OnClose.

--- On Mon, 11/17/08, Wilson, Stephen <[EMAIL PROTECTED]> wrote:

From: Wilson, Stephen <[EMAIL PROTECTED]>
Subject: [delphi-en] Multiple instances of form
To: [email protected]
Date: Monday, November 17, 2008, 3:03 AM






Hello All

I need to be able to show multiple instances of the same form, and to overcome 
the problem associated with closing such instances (closing one closes the 
rest) I do the following:
procedure TForm1.Button1Click (Sender: TObject);
begin
inc(c); 
Form2:= TForm2.Create( nil);
Form2.Name:= 'Form' + inttostr(c);
Form2.Show;
end;

procedure TForm2.FormShow( Sender: TObject);
begin
Button:= TButton.Create( self);
with Button do
begin
Parent:= self;
Tag:= Form1.c;
Height:= 25;
Width:= 75;
Caption:= 'Close';
OnClick:= DoClick;
end;
end;

procedure TForm2.DoClick( Sender: TObject);
begin
if copy(Name,5, 1) = inttostr(Button. Tag) then Release;
end;

This works, but there's probably a better way of achieving it; can anybody 
suggest one?

Thanks, as always, for any help....

Best wishes

Steve

************ ********* ********* ********* ********* ********* ********* 
*********
This e-mail and any files transmitted with it are confidential. If you are not 
the intended recipient, any reading, printing, storage, disclosure, copying or 
any other action taken in respect of this e-mail is prohibited and may be 
unlawful. If you are not the intended recipient, please notify the sender 
immediately by using the reply function and then permanently delete what you 
have received.
Content of emails received by this Trust will be subject to disclosure under 
the Freedom of Information Act 2000, subject to the specified exemptions, 
including the Data Protection Act 1998 and Caldicott Guardian principles.
This footnote also confirms that, unless otherwise stated, this email message 
has been swept by Sophos Anti-virus for the presence of computer viruses.
************ ********* ********* ********* ********* ********* ********* 
*********

 














      

[Non-text portions of this message have been removed]

Reply via email to