Solved

Component linking

Posted on 2001-07-14
1
185 Views
Last Modified: 2010-04-06
I have 2 components, one linked to the other via a property. Deleting the component which was selected by the other ends up with access violations. How can I capture this event and what should I do then?
Thanks,
Gurkan AKTAS
0
Comment
Question by:Gurkan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 3

Accepted Solution

by:
nnbbb09 earned 50 total points
ID: 6282267

You need to override the notification method which is declared in TComponent as :

procedure Notification(AComponent: TComponent; Operation: TOperation); virtual;

All you need to do is check if AComponent is the same as the object that you are interested in and if the Operation = opRemove. If both these conditions are true then set your object property to nil.

This is what TDBEdit does when it's datasource is deleted

procedure TDBEdit.Notification(AComponent: TComponent;
  Operation: TOperation);
begin
  inherited Notification(AComponent, Operation);
  if (Operation = opRemove) and (FDataLink <> nil) and
    (AComponent = DataSource) then DataSource := nil;
end;

Hope this helps

Jo
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question