Board index » cppbuilder » component member control manipulation

component member control manipulation


2004-06-23 04:07:36 PM
cppbuilder18
I have a pretty simple component that has a panel containing a groupbox
with radio buttons within it. I would like to surface the groupboxes
height and width properties so they can be changed in the object inspector.
Whats the best way to do this? I can't find anything about this in the
component writers guide.
Craig
 
 

Re:component member control manipulation

"Craig" < XXXX@XXXXX.COM >wrote in message
Quote
I would like to surface the groupboxes
height and width properties so they can be changed in the object inspector.
Whats the best way to do this?
Simply publish the properties. Create getter and setter functions to read and
write their values. Eg.;
class TMyControl: public TWhatEverBase {
protected:
void __fastcall SetGroupBoxHeight(int Value);
int __fastcall GetGroupBoxHeight();
void __fastcall SetGroupBoxWidth(int Value);
int __fastcall GetGroupBoxWidth();
__published:
__property int GroupBoxHeight={
read=GetGroupBoxHeight,
write=SetGroupBoxHeight
};
__property int GroupBoxWidth={
read=GetGroupBoxWidth,
write=SetGroupBoxWidth
};
};
Quote
I can't find anything about this in the
component writers guide.
Activate BCB's help system. Select the 'Contents' tabpage. Expand the topic
'Creating Custom Components|Creating properties'. Take your pick...
Ralph
 

Re:component member control manipulation

Cheers Ralph,
What I meant was I couldn't find anywhere it describes publishing nested
components properties.
Craig
 

{smallsort}

Re:component member control manipulation

"Craig" < XXXX@XXXXX.COM >wrote in message
Quote
What I meant was I couldn't find anywhere it describes publishing nested
components properties.
Nested properties can be achieved by publishing a TPerstistent*. Though that is
probably not what you want to do in this case, here goes;
class TMyControl: public TWhatEverBase {
protected:
TGroupBox* FGroupBox;
TPersistent* __fastcall GetGroupBox() {
return FGroupBox;
}
void __fastcall SetGroupBox(TPersistent* Value) {
// not implemented
}
public:
__fastcall TMyControl(TComponent* Owner);
inherited(Owner),
FGroupBox(new TGroupBox(this))
{
}
__published:
__property TPersistent* GroupBox={read=GetGroupBox,write=SetGroupBox};
};
Ralph