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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to clone TForm???

Status
Not open for further replies.

rcloutie

Programmer
May 26, 2005
164
CA
Hi there,

I'm using Delphi 2006...

Here's my code to clone a form (as written on about.com):
---------------------------------------
function FormClone(frm: TForm): TForm;
var ms: TMemoryStream;
begin
ms := TMemoryStream.Create;
try
ms.WriteComponent(frm);
ms.Position := 0;
Result := TFormClass(frm.ClassType).CreateNew(Application);
ms.ReadComponent(Result);
finally
ms.Free;
end;
end;
---------------------------------------
It results in an EComponentError:
A component named 'btnCancel' already exists.

How to solve this problem???

Thanks a lot,

RC
 
Hi,
I am not exactly sure why you are getting this error, reason for this error is once you have component named btnCancel and if you try again to create it, it gives this error, Reason for this can be known only if we know what component are their on your form.
 
Hi,
First, thanks for reply.
Second, I've found another way to do what I need to do.
Only to mark 'done' this problem...

btnOK and btnCancel are TBitBtn components.
There is also a home made VCL built from TStringGrid and
a frame containing TEdit, TProgressBar, TLabel and TBitBtn.

The error references btnCancel which is a single standard component. Maybe the error message displays a wrong component's name? Is there specific code to insert in my VCL?

Thanks a lot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top