Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi Designer, Is component inherited?

I'm writing a custom component editor, essentially similar to TActionList editor in that it allows creation of sub components. Editor has buttons to add/delete components.

Now, I'd like to find out if selected component is inherited, so that I can disable the delete button. I haven't found any such member in IDesigner or related interfaces.

If I just go ahead and delete by Designer.DeleteSelection(True); then I get an exception:

Selection contains a component, xxx, introduced in an ancestor and cannot be deleted.

Which is not too bad, but I'd prefer to disable the delete button in the first place.

like image 292
Daniel Maurić Avatar asked Mar 04 '13 19:03

Daniel Maurić


1 Answers

Ok, so apparently there is a way, by checking the TComponent.ComponentState for csAncestor, so:

csAncestor in ComponentState

And it's documented:

csAncestor - The component was introduced in an ancestor form. Only set if csDesigning is also set.

like image 151
Daniel Maurić Avatar answered Sep 24 '22 23:09

Daniel Maurić