Board index » cppbuilder » Show the collection property Editor for a sub-component property

Show the collection property Editor for a sub-component property


2004-07-19 10:34:56 PM
cppbuilder41
Hi all,
I've problems to show in object inspector, the editor for properties
(collection derived) for a sub component property. The oi displays a
element for this property, but a elipse click does not start the
collection editor .
Here some sample code:
//.hpp +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
class PACKAGE TComponent1 : public TComponent
{
typedef Classes::TComponent inherited;
private:
bool FTestbool;
TGroupEnableItems* FActionItems;
TGroups* FGroup1;
protected:
public:
__fastcall TComponent1(TComponent* Owner);
__published:
__property bool Testbool = { read=FTestbool, write=FTestbool };
__property TGroupEnableItems* ActionItems = {
read=FActionItems, write=FActionItems };
__property TGroups* Group1 = { read=FGrpup1, write=FGrpup1 };
};
//---------------------------------------------------------------------------
class TGroups : public TPersistent
{
private:
TGroupEnableItems* FActionItems;
bool FTestBool1;
AnsiString FString1;
TPersistent* FOwner;
public:
__fastcall TGroups();
__fastcall TGroups(TPersistent* AOwner);
__published:
__property TGroupEnableItems* ActionItems = {
read=FActionItems, write=FActionItems };
__property bool TestBool1 = { read=FTestBool1, write=FTestBool1 };
__property AnsiString String1 = { read=FString1, write=FString1 };
};
//---------------------------------------------------------------------------
class PACKAGE TGroupEnableItem: public TCollectionItem
{
public:
private:
...
protected:
...
__published:
...
};
//---------------------------------------------------------------------------
class PACKAGE TGroupEnableItems: public TCollection
{
typedef Classes::TPersistent inherited;
private:
TPersistent* FOwner;
protected:
DYNAMIC TPersistent* __fastcall GetOwner(void);
public:
__fastcall TGroupEnableItems(TPersistent* AOwner);
};
//.cpp+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
...
__fastcall TComponent1::TComponent1(TComponent* Owner)
: TComponent(Owner)
{
FActionItems= new TGroupEnableItems(this);
FGroup1 = new TGroups(this);
}
//---------------------------------------------------------------------------
__fastcall TGroups::TGroups()
{
FActionItems = new TGroupEnableItems(NULL);
}
__fastcall TGroups::TGroups(TPersistent* AOwner)
{
FActionItems = new TGroupEnableItems(AOwner);
}
I've here ActionItems twice:
- Once as property of Component1. A click on this element starts the
collection editor.
- Second as property of Groups. A click on this element does not starts
the collecction editor! Why?
Thanks for any ideas.
 
 

Re:Show the collection property Editor for a sub-component property

"Lars" < XXXX@XXXXX.COM >wrote in message news: XXXX@XXXXX.COM ...
Quote
I've problems to show in object inspector, the editor for properties
(collection derived) for a sub component property. The oi displays a
element for this property, but a elipse click does not start the
collection editor .
A TGroups::GetOwner() method must be implemented.
I took the liberty of rewriting your code:
class PACKAGE TGroupEnableItem: public TCollectionItem
{
typedef TCollectionItem inherited;
int FValue1;
public:
__fastcall TGroupEnableItem( TCollection* ACollection );
__published:
__property int Value1 = { read=FValue1, write=FValue1 };
};
//---------------------------------------------------------------------------
class PACKAGE TGroupEnableItems: public TOwnedCollection
{
typedef TOwnedCollection inherited;
public:
__fastcall TGroupEnableItems(TPersistent* AOwner);
TGroupEnableItem* __fastcall Add();
};
//---------------------------------------------------------------------------
class PACKAGE TGroups : public TPersistent
{
typedef TPersistent inherited;
TGroupEnableItems* FActionItems;
bool FTestBool1;
AnsiString FString1;
TPersistent* FOwner;
public:
__fastcall TGroups(TPersistent* AOwner);
__fastcall ~TGroups();
DYNAMIC TPersistent* __fastcall GetOwner();
__published:
__property TGroupEnableItems* ActionItems = { read=FActionItems, write=FActionItems };
__property bool TestBool1 = { read=FTestBool1, write=FTestBool1 };
__property AnsiString String1 = { read=FString1, write=FString1 };
};
//---------------------------------------------------------------------------
class PACKAGE TComponent1 : public TComponent
{
typedef TComponent inherited;
bool FTestbool;
TGroupEnableItems* FActionItems;
TGroups* FGroup1;
public:
__fastcall TComponent1(TComponent* Owner);
__fastcall ~TComponent1();
__published:
__property bool Testbool = { read=FTestbool, write=FTestbool };
__property TGroupEnableItems* ActionItems = { read=FActionItems, write=FActionItems };
__property TGroups* Group1 = { read=FGroup1, write=FGroup1 };
};
//---------------------------------------------------------------------------
__fastcall TGroupEnableItem::TGroupEnableItem( TCollection* ACollection )
: TCollectionItem(ACollection)
{
}
//----------------------------------------------------------------------------
__fastcall TGroupEnableItems::TGroupEnableItems( TPersistent* AOwner )
: TOwnedCollection( AOwner, __classid(TGroupEnableItem) )
{
}
TGroupEnableItem* __fastcall TGroupEnableItems::Add()
{
return (TGroupEnableItem*) inherited::Add();
}
//----------------------------------------------------------------------------
__fastcall TGroups::TGroups(TPersistent* AOwner)
: TPersistent(), FOwner(AOwner)
{
FActionItems = new TGroupEnableItems(AOwner);
}
__fastcall TGroups::~TGroups()
{
delete FActionItems;
}
TPersistent* __fastcall TGroups::GetOwner()
{
return FOwner;
}
//----------------------------------------------------------------------------
__fastcall TComponent1::TComponent1(TComponent* Owner)
: TComponent(Owner)
{
FActionItems = new TGroupEnableItems(this);
FGroup1 = new TGroups(this);
}
__fastcall TComponent1::~TComponent1()
{
delete FGroup1;
delete FActionItems;
}
Todd
 

Re:Show the collection property Editor for a sub-component property

Todd Brylski schrieb:
Quote
"Lars" < XXXX@XXXXX.COM >wrote in message news: XXXX@XXXXX.COM ...

>I've problems to show in object inspector, the editor for properties
>(collection derived) for a sub component property. The oi displays a
>element for this property, but a elipse click does not start the
>collection editor .


A TGroups::GetOwner() method must be implemented.
I took the liberty of rewriting your code:

class PACKAGE TGroupEnableItem: public TCollectionItem
{
typedef TCollectionItem inherited;

int FValue1;

public:
__fastcall TGroupEnableItem( TCollection* ACollection );

__published:
__property int Value1 = { read=FValue1, write=FValue1 };

};
//---------------------------------------------------------------------------

class PACKAGE TGroupEnableItems: public TOwnedCollection
{
typedef TOwnedCollection inherited;

public:
__fastcall TGroupEnableItems(TPersistent* AOwner);
TGroupEnableItem* __fastcall Add();
};
//---------------------------------------------------------------------------

class PACKAGE TGroups : public TPersistent
{
typedef TPersistent inherited;

TGroupEnableItems* FActionItems;
bool FTestBool1;
AnsiString FString1;
TPersistent* FOwner;

public:
__fastcall TGroups(TPersistent* AOwner);
__fastcall ~TGroups();
DYNAMIC TPersistent* __fastcall GetOwner();

__published:
__property TGroupEnableItems* ActionItems = { read=FActionItems, write=FActionItems };
__property bool TestBool1 = { read=FTestBool1, write=FTestBool1 };
__property AnsiString String1 = { read=FString1, write=FString1 };
};
//---------------------------------------------------------------------------

class PACKAGE TComponent1 : public TComponent
{
typedef TComponent inherited;

bool FTestbool;
TGroupEnableItems* FActionItems;
TGroups* FGroup1;

public:
__fastcall TComponent1(TComponent* Owner);
__fastcall ~TComponent1();

__published:
__property bool Testbool = { read=FTestbool, write=FTestbool };
__property TGroupEnableItems* ActionItems = { read=FActionItems, write=FActionItems };
__property TGroups* Group1 = { read=FGroup1, write=FGroup1 };
};
//---------------------------------------------------------------------------

__fastcall TGroupEnableItem::TGroupEnableItem( TCollection* ACollection )
: TCollectionItem(ACollection)
{
}
//----------------------------------------------------------------------------

__fastcall TGroupEnableItems::TGroupEnableItems( TPersistent* AOwner )
: TOwnedCollection( AOwner, __classid(TGroupEnableItem) )
{
}

TGroupEnableItem* __fastcall TGroupEnableItems::Add()
{
return (TGroupEnableItem*) inherited::Add();
}
//----------------------------------------------------------------------------

__fastcall TGroups::TGroups(TPersistent* AOwner)
: TPersistent(), FOwner(AOwner)
{
FActionItems = new TGroupEnableItems(AOwner);
}

__fastcall TGroups::~TGroups()
{
delete FActionItems;
}

TPersistent* __fastcall TGroups::GetOwner()
{
return FOwner;
}
//----------------------------------------------------------------------------

__fastcall TComponent1::TComponent1(TComponent* Owner)
: TComponent(Owner)
{
FActionItems = new TGroupEnableItems(this);
FGroup1 = new TGroups(this);
}

__fastcall TComponent1::~TComponent1()
{
delete FGroup1;
delete FActionItems;
}

Todd


Hi Todd,
Many, many thanks. You have point me on the right direction.
Lars
 

{smallsort}

Re:Show the collection property Editor for a sub-component property

"Lars" < XXXX@XXXXX.COM >wrote in message
Quote
Many, many thanks. You have point me on the right direction.
For future reference, please trim your replies.
Gambit