Board index » delphi » Deriving a New form type

Deriving a New form type

I want to derive a new form type from (TForm) for use in projects. I
would prefer to do this as opposed to installing a Template. Can I
actually do this? If so how do I install the derived form so that I can
use it. Currently I define a form and install it as a template, this
means I have a copy of the form I installed. Instead of a copy when I
use the template I want a new form which is derived from the template. I
want to be able to add to this and edit in the same way as though it was
a normal form derived from TForm. Any thoughts?

thanks,

barney dalton

 

Re:Deriving a New form type


Quote
Barney Dalton <b...@techprt.co.uk> wrote:
>I want to derive a new form type from (TForm) for use in projects. I
>would prefer to do this as opposed to installing a Template. Can I
>actually do this? If so how do I install the derived form so that I can
>use it. Currently I define a form and install it as a template, this
>means I have a copy of the form I installed. Instead of a copy when I
>use the template I want a new form which is derived from the template. I
>want to be able to add to this and edit in the same way as though it was
>a normal form derived from TForm. Any thoughts?

>thanks,

Ahh, that would be nice.  I think 2.0 does something like what you
want.  In the meantime, you have to stick your TMyForm in a unit and
then manually change the declaration for your form type to be
descended from your custom type.  i.e. change

TForm1 = class(TForm)

to

TForm1 = class(TMyForm)

in each form unit.  There may be more to it, I hvae only read about it
and not actually done it.  I have found it easier to encapsulate
functionality into a component that I can just drop onto a "standard"
form.

If you have the VCL source, you could hack your changes right into
TForm.  ;)
--
Tim Shea
CSI
c...@citysoft.com

Re:Deriving a New form type


Quote
In article <3123AA46.2...@techprt.co.uk> Barney Dalton <b...@techprt.co.uk> writes:
>From: Barney Dalton <b...@techprt.co.uk>
>Subject: Deriving a New form type
>Date: Thu, 15 Feb 1996 13:48:54 -0800
>I want to derive a new form type from (TForm) for use in projects. I
>would prefer to do this as opposed to installing a Template. Can I
>actually do this? If so how do I install the derived form so that I can
>use it. Currently I define a form and install it as a template, this
>means I have a copy of the form I installed. Instead of a copy when I
>use the template I want a new form which is derived from the template. I
>want to be able to add to this and edit in the same way as though it was
>a normal form derived from TForm. Any thoughts?

>thanks,
>barney dalton

wot i do is have a seperate directory { in my case called common} which all
projects refer to - using options | project. In that dir I have a file with
the new form class in - in fact i have a couple of derived forms - usually
with different variations of overriding the createparams method, and also
various execute methods. These are declared as simple objects, and they have no
visual representation e.g.

  tmynewform = class (tform)

end;

NB in the Implementation part, there is no {$ *.dfm} - hence no res., and no
design time view

In my main project, when i want a subclassed form - ie one that dervies from
one of these, all i do is change the ancestor of the form I'm currently using
- and it works fine eg if I had a dialog that i wanted to get some
functionality from tmynewform, i change it's declaration from

 tdialog = class(tform)

to

 tdialog = class(tmynewform)

HTH

Boris Ingram, Cyborg Software
boris...@iafrica.com
http://www.pcb.co.za/users/borising/cyborg.htm

Other Threads