Solved

Component linking

Posted on 2001-07-14
1
180 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi 2010 Export to pdf 2 288
Virtualstringtree carsh after invalidate for while 5 87
Virtuailstring tree compare node issue 14 105
Using idhttp to login to instagram 2 76
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

863 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now