I'm developing a component with a method to clone Panels or other
components,
example:
I have into form1 a TPanel component with lot of controls over it (edits,
buttons
with events, etc...). Into Form1 i have a button that creates at runtime a
form and
does a showmodal of it. How can i create a panel into the new runtime form
copy
from the panel of Form1 (with exactly all the controls, events, ...)? I can
do it
easily setting the parent of the panel to the new form, but then the panel
dissapears
from Form1 and i dont wish this, i wish do an independent copy.
Thanks for all.
Naturally, put try..finally where required.
--
Robert
ladrillo wrote in message <3d85...@newsgroups.borland.com>...
I'm using Delphi 6, where is the problem? Thanks for all
Robert Cerny <robert.q...@neosys.xrs.qwe.si> escribió en el mensaje de
noticias am5g1...@neosys.xrs.si...
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.386 / Virus Database: 218 - Release Date: 09/09/2002
"ladrillo" <progra...@elladrillorojo.com> wrote in message
news:3d883cf8$1...@newsgroups.borland.com...
> I need a generic function, i have lots of differents panels with
> differents components into them, so and due the system i'm developing
> i need a function or method to clone a entire panel, but not alway the
> same.
>
> Thanks
>
>
> Gabriel B <gbong...@hotmail.com> escribió en el mensaje de noticias
> 3d87...@newsgroups.borland.com...
> > Why not create a component with that Panel?
"ladrillo" <progra...@elladrillorojo.com> wrote in message
news:3d883cf8$1...@newsgroups.borland.com...
> I need a generic function, i have lots of differents panels with
> differents components into them, so and due the system i'm developing
> i need a function or method to clone a entire panel, but not alway the
> same.
>
> Thanks
>
>
> Gabriel B <gbong...@hotmail.com> escribió en el mensaje de noticias
> 3d87...@newsgroups.borland.com...
> > Why not create a component with that Panel?
> >
> I need a generic function, i have lots of differents panels with
> differents components into them, so and due the system i'm developing
> i need a function or method to clone a entire panel, but not alway the
> same.
>
There are a couple of ways to accomplish this.
1) create a function like the following.
Type
TPanelClass = Class of TPanel;
Function
CreatePanel(Panel:TPanelClass;AOwner:Tcomponent;AParent:TComponent):TPanel;
Begin
Result := Panel.create(AOwner);
Result.parent:=AParent;
end;
You call it like this
CreatePanel(TMyPanel,TMyform,TMyform);
Or
2) You have to register each panel class you
wish to be able to use create at runtime
using the registerclass procedure.
And then you use the findclass procedure
to retreive a class variable Typecast it
to a TPanel class and use it the same way
I have on the above function.
Regards
Johnnie.