Custom property editor that can access other properties of a component.

I have a component that has a custom property editor for one of its properties. The editor provides a drop-down list of items that the user can select, this works as expected. I would like to modify the editor so that the list of items in the drop-down list depends also on the value of another property in the same component.

How do I design a custom property editor that can access a property of a component other than the property for which the editor is registered?

Regards
FarmerJo
0
John
2/28/2014 9:32:55 PM
📁 embarcadero.cppbuilder.writing
📃 359 articles.
⭐ 0 followers.

💬 2 Replies
👁️‍🗨️ 949 Views

John wrote:

> How do I design a custom property editor that can access a property
> of a component other than the property for which the editor is
> registered?

Use the GetComponent() method to retreive a pointer to the component that 
is being edited, then type-cast it to your component's class type in order 
to access other members of it.

For example:

{code}
void __fastcall TMyPropEditor::GetValues(TGetStrProc Proc)
{
    TMyComponent *Comp = (TMyComponent*) GetComponent(0);
    // use Comp as needed, calling Proc() for each desired value ...
}
{code}

--
Remy Lebeau (TeamB)
0
Remy
3/1/2014 12:13:28 AM
> {quote:title=Remy Lebeau (TeamB) wrote:}{quote}
> John wrote:
> 
> > How do I design a custom property editor that can access a property
> > of a component other than the property for which the editor is
> > registered?
> 
> Use the GetComponent() method to retreive a pointer to the component that 
> is being edited, then type-cast it to your component's class type in order 
> to access other members of it.
> 
> For example:
> 
> {code}
> void __fastcall TMyPropEditor::GetValues(TGetStrProc Proc)
> {
>     TMyComponent *Comp = (TMyComponent*) GetComponent(0);
>     // use Comp as needed, calling Proc() for each desired value ...
> }
> {code}
> 
> --
> Remy Lebeau (TeamB)

Hi Remy,

Many thanks for the quick answer, once again it has been a great help.

Cheers, FamerJohn
0
John
3/2/2014 6:40:05 PM
Reply: