I have a component decended from TComponent (Component A). One of its published properties is another component (Component B). At design time I can select a component from the form for this property in the object inspector.
The problem is this:
When I delete Component B from the form, the refernce remains in Component A. This upsets Delphi enormously and causes all sorts of access violations. I cannot alter the code for Component B (it could be a VCL object for example) so what is the correct solution for this problem.
Somehow when Component B is deleted, Component A must Nil its reference. Perhaps I should listen for a message in Component A? if so which one? Maybe there is something I can do with csDesigning flag? Any ideas?
An Example :
TComponentA = class(TComponent)
fComponentB : TComponent;
property ComponentB : TComponent read fComponentB write fComponentB ;