Board index » cppbuilder » Hiding component at design-time in form but not in object inspector

Hiding component at design-time in form but not in object inspector

Hi to all,

I've got a component whose component editor creates lots of subcomponents at
design time. I want to be able to access the subcomponents' properties with
the object inspector, as well as saving all the properties to the form file.
I can do this by setting the owner property of the created subcomponents to
the form, but in this case I get lots of icons in the top-left corner of the
form.

How can I make all these subcomponents invisible in the form but visible in
the object inspector?

Is it possible in any other way to see a component in the object inspector
and save its properties to the form file without setting its owner property
to the form?

I've noticed that the TChartSeries component works exactly like this, but
there's no source code for it.

Thanks very much to all,
P. Mateu

 

Re:Hiding component at design-time in form but not in object inspector


Quote
"Pere Mateu" <pma...@ono.com> wrote in message

news:3e5d5576$1@newsgroups.borland.com...

Quote
> I've got a component whose component editor creates
> lots of subcomponents at design time.

What kind of subcomponents exactly?  Please be more specific.

Quote
> How can I make all these subcomponents invisible in the form
> but visible in the object inspector?

By not setting the Owner/Parent to the form to begin with.  They should be
set to the component that is being edited, as they are supposed to be part
of the component, not separated and placed on the form directly (unless your
component is a manager that simply creates instances that it does not
directly own, in which case what you describe should be expected behavior
for your component).  What EXACTLY are you trying to accomplish with your
editor?

Quote
> Is it possible in any other way to see a component in the
> object inspector and save its properties to the form file
> without setting its owner property to the form?

Make the components part of the edited component itself, with access exposed
via published properties in the component.

Gambit

Re:Hiding component at design-time in form but not in object inspector


Hi again,

Quote
> > I've got a component whose component editor creates
> > lots of subcomponents at design time.

> What kind of subcomponents exactly?  Please be more specific.

They are TComponent derived classes with some basic properties.

I'll try to explain what I try to do with other words. I have a component
with a property that's a container for other subcomponents (lots of them). I
could set a TCollection property in the container component and define the
subcomponents as TCollectionItem descendants, but this is not valid for me
because:

a) I want to access the subcomponents directly from the object inspector and
the code. If I define a subcomponent called MySubcomponent, I want to be
able to reference it in my code by its name (for example:
MySubcomponent->Tag=1). I can't do this if I use TCollectionItem
descendants. Also, my subcomponents can be of different classes (although
they are all based in the same ancestor class). I'm not sure if this is
possible with TCollection, but I don't think so.

b) I want a customized component editor for the container component, because
I need to import and export -at design time as well as at runtime- the
configuration of all the subcomponents from external text files generated
with other programs. This is the reason why I get lots of subcomponents:
when I import a configuration file, I must create all the subcomponents
defined in it.

As I said in the previous mail, the TChartSeries component behaves exactly
like this. You define TChartSeries descendants in the TChart editor, and
after that you can see the TChartSeries components in the object inspector
and you also can reference them in your code.

Hope all this helps a little bit more.

Thanks very much again for your invaluable help,
P. Mateu

Re:Hiding component at design-time in form but not in object inspector


All that is doing is creating new instances of the subcomponents
dynamically, assigning the form as the Owner and the TChart as the Parent.
To create the components at design-time, TComponentEditor has a Designer
property which in turn has a CreateComponent() method.

Gambit

Quote
"Pere Mateu" <pma...@ono.com> wrote in message

news:3e5e723b$1@newsgroups.borland.com...
Quote
> As I said in the previous mail, the TChartSeries component
> behaves exactly like this.  You define TChartSeries descendants
> in the TChart editor, and after that you can see the TChartSeries
> components in the object inspector and you also can reference
> them in your code.

Re:Hiding component at design-time in form but not in object inspector


Quote
Pere Mateu wrote:
> How can I make all these subcomponents invisible in the form but visible in
> the object inspector?

You can position them off the form by setting their Top and/or Left properties
to negative values, such as -100.

Re:Hiding component at design-time in form but not in object inspector


Quote
Fishface wrote:
> You can position them off the form by setting their Top and/or Left
> properties to negative values, such as -100.

Ah, but of course they don't have those properties.  It seem that at
design time, non-visual components are represented by windows
of type TContainer, which are children of the form.  Maybe you
can find them and hide them.

Re:Hiding component at design-time in form but not in object inspector


Quote
> All that is doing is creating new instances of the subcomponents
> dynamically, assigning the form as the Owner and the TChart as the Parent.
> To create the components at design-time, TComponentEditor has a Designer
> property which in turn has a CreateComponent() method.

That's ok. I've also discovered that TField descendants work in the same
way: their owner is the form and their parent is the dataset. But they -as
well as TChartSeries components- don't appear in the form. If I create my
subcomponents and do the same, everything works the way I want excet that I
keep seeing lots of icons in the top-left corner of the form.

Any further ideas?

P. Mateu

Re:Hiding component at design-time in form but not in object inspector


Quote
"Pere Mateu" <pma...@ono.com> wrote in message

news:3e5eaf62@newsgroups.borland.com...

Quote
> I've also discovered that TField descendants work in the
> same way: their owner is the form and their parent is the
> dataset. But they -as well as TChartSeries components-
> don't appear in the form.

I tested TChart and its editor.  The sub-charts do indeed appear on the
form - as children of the Parent TChart.  TChart itself is a visual
component and the individual TChart series are displayed visually inside of
it because they are also visual components.  However, they do not appear in
the Object Inspector.  TChart has its own custom editor for editing the
chart series.  It has nothing to do with the Object Inspector at all.

TField instances, on the other hand, are not visual components to begin
with, and their Parent is a TDataSet, which is also not a visual component
itselves, thus there's nothing to display visual on the form as far as the
individual TField instances go.

Quote
> If I create my subcomponents and do the same, everything
> works the way I want excet that I keep seeing lots of icons in
> the top-left corner of the form.

Your components are not visual ones, I gather?  Using the
ComponentEditor->Designer->CreateComponent() method, you can specify where
the components are placed on the form.

Gambit

Re:Hiding component at design-time in form but not in object inspector


Quote
Remy  wrote:
> Your components are not visual ones, I gather?  Using the
> ComponentEditor->Designer->CreateComponent() method,
> you can specify where the components are placed on the form.

...or off the form.  There you go!

This may also be of interest:
http://groups.google.com/groups?selm=4d48vd%24rbq%40cantua.canterbury...

Other Threads