 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Phil Grace Guest
|
Posted: Wed Jan 21, 2004 2:42 pm Post subject: How do I change a Form ancestor type. |
|
|
ENV : Delphi 7
Hi I have a project with quite a few forms, all derived from TForm.
What I would like to do is create a TBaseForm (derived from TForm),
put some common functionality in it, and have all my other forms
derive from TBaseForm rather than TForm.
I've tried to do this by simply using a text editor (outside of
Delphi) to change the class of the form to TBaseForm, but this seems
to have no effect (it even compiles ok, but doesn't inherit the
"middle" form).
How can I do this without building all my forms from the gound up.
Cheers,
Phil.
|
|
| Back to top |
|
 |
J French Guest
|
Posted: Wed Jan 21, 2004 7:17 pm Post subject: Re: How do I change a Form ancestor type. |
|
|
On 21 Jan 2004 08:42:13 -0600, Phil Grace <phil (AT) niche-cs (DOT) com> wrote:
| Quote: | ENV : Delphi 7
Hi I have a project with quite a few forms, all derived from TForm.
What I would like to do is create a TBaseForm (derived from TForm),
put some common functionality in it, and have all my other forms
derive from TBaseForm rather than TForm.
|
Sensible
| Quote: |
I've tried to do this by simply using a text editor (outside of
Delphi) to change the class of the form to TBaseForm, but this seems
to have no effect (it even compiles ok, but doesn't inherit the
"middle" form).
|
What ????
| Quote: | How can I do this without building all my forms from the gound up.
|
Just create a Unit
.... but I suggest that you try simpler things first
|
|
| Back to top |
|
 |
Maarten Wiltink Guest
|
Posted: Wed Jan 21, 2004 8:33 pm Post subject: Re: How do I change a Form ancestor type. |
|
|
"Phil Grace" <phil (AT) niche-cs (DOT) com> wrote
| Quote: | Hi I have a project with quite a few forms, all derived from TForm.
What I would like to do is create a TBaseForm (derived from TForm),
put some common functionality in it, and have all my other forms
derive from TBaseForm rather than TForm.
I've tried to do this by simply using a text editor (outside of
Delphi) to change the class of the form to TBaseForm, but this seems
to have no effect (it even compiles ok, but doesn't inherit the
"middle" form).
How can I do this without building all my forms from the gound up.
|
Simply changing the source code after the fact is good enough for
most cases, but if you insist, you can use File/New on the IDE menu
and pick an existing form from the tab named after your program.
How do you tell the middle form isn't inherited? It probably is.
Not everything works that we'd all like to. Notably, you can add
published properies to it, but those don't show up in the Object
Inspector.
Groetjes,
Maarten Wiltink
|
|
| Back to top |
|
 |
Phil Grace Guest
|
Posted: Wed Jan 21, 2004 9:06 pm Post subject: Re: How do I change a Form ancestor type. |
|
|
On Wed, 21 Jan 2004 19:17:17 +0000 (UTC), [email]erewhon (AT) nowhere (DOT) com[/email] (J
French) wrote:
| Quote: | On 21 Jan 2004 08:42:13 -0600, Phil Grace <phil (AT) niche-cs (DOT) com> wrote:
ENV : Delphi 7
Hi I have a project with quite a few forms, all derived from TForm.
What I would like to do is create a TBaseForm (derived from TForm),
put some common functionality in it, and have all my other forms
derive from TBaseForm rather than TForm.
Sensible
I've tried to do this by simply using a text editor (outside of
Delphi) to change the class of the form to TBaseForm, but this seems
to have no effect (it even compiles ok, but doesn't inherit the
"middle" form).
What ????
|
Ok.... so lets say I used to have TMyForm ->TForm, and that what I
want is TMyForm -> TBaseForm -> TForm !
What I did was create TBaseForm and put some stuff in there... notably
visual components that would let me see immediately when it worked.
Then I edited TMyForm to inherit from class TBaseForm instead of
TForm. This seems to have NO effect whatsoever. Non of the visual
components in TBaseForm show up, and the app compiles without error !
| Quote: |
How can I do this without building all my forms from the gound up.
Just create a Unit
... but I suggest that you try simpler things first
|
Yes, I can do that, but my point is that I already have a ton of forms
that I want to change the class of, and don't want to manually
re-create each one with a new unit based on TBaseForm.
Regards,
Phil.
|
|
| Back to top |
|
 |
Maarten Wiltink Guest
|
Posted: Wed Jan 21, 2004 9:28 pm Post subject: Re: How do I change a Form ancestor type. |
|
|
"Phil Grace" <phil (AT) niche-cs (DOT) com> wrote
[...]
| Quote: | Ok.... so lets say I used to have TMyForm ->TForm, and that what I
want is TMyForm -> TBaseForm -> TForm !
What I did was create TBaseForm and put some stuff in there... notably
visual components that would let me see immediately when it worked.
Then I edited TMyForm to inherit from class TBaseForm instead of
TForm. This seems to have NO effect whatsoever. Non of the visual
components in TBaseForm show up, and the app compiles without error !
|
The effect of that is going to be that your forms inherit some published
fields from TBaseForm, but the matching initialisation data aren't in
the .dfm files, so nothing happens.
I think that's what happens; it should be easy to check. The fields
should all exist and contain nil at run-time.
| Quote: | How can I do this without building all my forms from the gound up.
Just create a Unit
... but I suggest that you try simpler things first
Yes, I can do that, but my point is that I already have a ton of forms
that I want to change the class of, and don't want to manually
re-create each one with a new unit based on TBaseForm.
|
Many other things _will_ work. Try putting a visual component on TBaseForm
in code (and don't forget to set its Parent) to see if it works. I think
it will.
Groetjes,
Maarten Wiltink
|
|
| Back to top |
|
 |
Phil Grace Guest
|
Posted: Thu Jan 22, 2004 10:01 am Post subject: Re: How do I change a Form ancestor type. |
|
|
On Thu, 22 Jan 2004 01:43:59 +0100, "Bjørge Sæther"
<bjorge (AT) hahaha_itte (DOT) no> wrote:
| Quote: | Phil Grace wrote:
On Wed, 21 Jan 2004 19:17:17 +0000 (UTC), [email]erewhon (AT) nowhere (DOT) com[/email] (J
French) wrote:
On 21 Jan 2004 08:42:13 -0600, Phil Grace <phil (AT) niche-cs (DOT) com> wrote:
ENV : Delphi 7
Hi I have a project with quite a few forms, all derived from TForm.
What I would like to do is create a TBaseForm (derived from TForm),
put some common functionality in it, and have all my other forms
derive from TBaseForm rather than TForm.
Sensible
I've tried to do this by simply using a text editor (outside of
Delphi) to change the class of the form to TBaseForm, but this seems
to have no effect (it even compiles ok, but doesn't inherit the
"middle" form).
What ????
Ok.... so lets say I used to have TMyForm ->TForm, and that what I
want is TMyForm -> TBaseForm -> TForm !
What I did was create TBaseForm and put some stuff in there... notably
visual components that would let me see immediately when it worked.
Then I edited TMyForm to inherit from class TBaseForm instead of
TForm. This seems to have NO effect whatsoever. Non of the visual
components in TBaseForm show up, and the app compiles without error !
How can I do this without building all my forms from the gound up.
Just create a Unit
... but I suggest that you try simpler things first
Yes, I can do that, but my point is that I already have a ton of forms
that I want to change the class of, and don't want to manually
re-create each one with a new unit based on TBaseForm.
Here's what is found in a .dfm file of an inherited form:
inherited frmAdressat: TfrmAdressat
Left = 397
Top = 375
Width = 785
Height = 465
Caption = 'Adressat: Adressatdata'
PixelsPerInch = 96
TextHeight = 13
inherited Panel1: TPanel
Width = 777
Height = 419
inherited PageControl1: TPageControl
Width = 777
Height = 419
ActivePage = tbshtDetalj
inherited tbshtOversikt: TTabSheet
inherited DBGrid1: TDBGrid
Width = 769
Height = 391
PopupMenu = PopupStdFilter
OnCellClick = DBGrid1CellClick
OnMouseMove = DBGrid1MouseMove
end
end
...you see the difference ? 'inherited' BlaBlaBla is referring to a
component in the ancestor form, while 'object' is a component inserted in
the current form class.
It would probably be possible to modify this in a text editor, but it may be
a lot of work. And...do take a backup first....
|
Hmm... that looks pretty scary doesn't it ... oh well I was hoping
there'd be a re-ancestor functions somewhere, but I guess I'll have to
do it all manually :-)
Thanks everyone ,
Phil.
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|