Board index » delphi » TCoolbar & Form Inheritance

TCoolbar & Form Inheritance

Can anyone tell me why you can't use form inheritance with TCoolbars
(also TNotebook, TTabbedNotebook)?

I have looked into the newsgroup archives and have found that a
TCoolbar's constructor has csInheritable (ComponentStyle) removed.  Why
is this?

Will it cause any problems if I subclass it and put it back in?

Tim

 

Re:TCoolbar & Form Inheritance


Quote
Tim Edwards wrote in message <353379FF.2...@venton.co.uk>...
>Can anyone tell me why you can't use form inheritance with TCoolbars
>(also TNotebook, TTabbedNotebook)?

Because they all manange their own internal list of child controls.  You can
subclass and restore the flag, but you need to be sure you don't try to add
buttons in a descendent form.  Delphi's streaming mechanism will barf
(that's a technical term <g>).

Re:TCoolbar & Form Inheritance


Scott Samet [TeamB] <ssa...@spam.me.not> wrote in article
<6h29f7$5...@forums.borland.com>...

Quote

> Tim Edwards wrote in message <353379FF.2...@venton.co.uk>...

> >Can anyone tell me why you can't use form inheritance with TCoolbars
> >(also TNotebook, TTabbedNotebook)?

> Because they all manange their own internal list of child controls.  You
can
> subclass and restore the flag, but you need to be sure you don't try to
add
> buttons in a descendent form.  Delphi's streaming mechanism will barf
> (that's a technical term <g>).

Scott,

Can you expound upon this a bit more?  I have subclassed
TCoolBar and restored the flag.  I also add buttons in
descendent forms and have observed no ill effects.  It
may be that there is a problem under certain conditions
which are not present in my application.  I have
carefully stepped through the VCL and examined the DFM's
and I can see no problems.  A little more detail might
help me to see the danger -- so far, no barfing.

Thanks
William
--
William Tucker
Compu-Share, Inc.

WTuc...@Compu-Share.com
William.Tuc...@worldnet.att.net

Re:TCoolbar & Form Inheritance


Quote
William Tucker wrote in message <01bd687a$fae9b140$5600010a@william>...
>Can you expound upon this a bit more?  I have subclassed
>TCoolBar and restored the flag.  I also add buttons in
>descendent forms and have observed no ill effects.  It
>may be that there is a problem under certain conditions
>which are not present in my application.  I have
>carefully stepped through the VCL and examined the DFM's
>and I can see no problems.  A little more detail might
>help me to see the danger -- so far, no barfing.

Try putting a coolbar and buttons on the ancestor form, then adding buttons
on the descendent form.  Then close and reopen the project and the two
forms.  I think that should show the problem.

Re:TCoolbar & Form Inheritance


Scott Samet [TeamB] <ssa...@spam.me.not> wrote in article
<6h4pl6$8...@forums.borland.com>...

Quote

> Try putting a coolbar and buttons on the ancestor form, then adding
buttons
> on the descendent form.  Then close and reopen the project and the two
> forms.  I think that should show the problem.

Scott,

I did this very thing -- no observable problems.  Here is exactly what I
did:

I created a new application
I dropped a TMyCoolBar onto the TForm1.
I dropped a TToolBar onto it and added a couple of buttons
I did a File/New and chose Project1 Form1 and inherited from it.
I added a couple more buttons to the ToolBar.
I saved the project.
I closed it
I did a reopen -- no problems that I observed.

What was supposed to happen?

William
--
William Tucker
Compu-Share, Inc.

WTuc...@Compu-Share.com
William.Tuc...@worldnet.att.net

Re:TCoolbar & Form Inheritance


Quote
William Tucker wrote in message <01bd6954$2a051f30$5600010a@william>...
>What was supposed to happen?

I think the breakage occurs when you add a new control directly to the
coolbar.

Re:TCoolbar & Form Inheritance


Scott Samet [TeamB] <ssa...@spam.me.not> wrote in article
<6h5o9i$9...@forums.borland.com>...

Quote

> I think the breakage occurs when you add a new control directly to the
> coolbar.

Got it!  Thanks, Scott.

William
--
William Tucker
Compu-Share, Inc.

WTuc...@Compu-Share.com
William.Tuc...@worldnet.att.net

Re:TCoolbar & Form Inheritance


Quote
In article <01bd6984$a081e9b0$5600010a@william>, William Tucker wrote:
> Got it!  Thanks, Scott.

Just out of curiosity, how did it present?

Re:TCoolbar & Form Inheritance


Scott Samet <s...@me.not> wrote in article
<VA.00000005.00788f39@keywest>...

Quote
> In article <01bd6984$a081e9b0$5600010a@william>, William Tucker wrote:

> Just out of curiosity, how did it present?

What I meant by 'got it' was that that makes it not an issue for us --
so, I didn't actually try it.  I have since tried it, though.

I have experimented with the ancestor and descendant forms' CoolBars
adding various types of controls to both and have observed no ill
behaviors.  Even stepping through the VCL shows no obvious problems.

In our particular case, we never add new controls directly to the
CoolBar -- just buttons on the inherited ToolBar in the CoolBar.  So,
even if it does mess up, it is not an issue for us.  But, I cannot
get it to mess up as you suggest.

I guess you are still interested in pursuing this, and for the
benefit of others, so am I.  I still have not been able to figure
out why the TCoolBar explicitly removes csInheritable.  I have
observed no problems when I add it back in a subclass.

I am increasingly coming to believe that adding it back is perfectly
safe.

Thanks,
William
--
William Tucker
Compu-Share, Inc.

WTuc...@Compu-Share.com
William.Tuc...@worldnet.att.net

Re:TCoolbar & Form Inheritance


Quote
In article <01bd6a1b$69aeb340$5600010a@william>, William Tucker wrote:
> I am increasingly coming to believe that adding it back is perfectly
> safe.

The Borland folks that wrote the VCL are pretty sharp, and while I may
not know exactly how it blows up, and you many not run into in your
code, that does lead to "perfectly safe".

I'll see if I can get more info.

Other Threads