BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

sub-properties events

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Writing
View previous topic :: View next topic  
Author Message
PlutoPlanet
Guest





PostPosted: Fri Dec 29, 2006 6:25 pm    Post subject: sub-properties events Reply with quote



Hello World

I wrote a component (MyComponent) that contains a TSQLConnection as
subproperty.

property MyConnection: TSQLConnection read FConnection write
SetMyConnection;

To be informed when a connection is being established I did the
following:

procedure TMyComponent.SetMyConnection( Value: TSQLConnection )
begin
if Value <> nil then
begin
Self.MyConnection.AfterConnect := Self.HandleConnect;
end;
end;

procedure TMyComponent.HandleConnect( Sender: TObject )
begin
// do some stuff
end;

This works pretty good as long as there is a TSQLConnection connected
with only one TMyComponent.
As soon as I have 2 or more TMyComponents connected with the same
TSQLConnection it doesn't work anymore because the TSQLConnection's
AfterConnect only points to the last one beeing selected within
TMyComponent.
What is the right way getting notified about events of sub-properties?

Thanks,
Herwig
Back to top
Erich Günthner
Guest





PostPosted: Thu Jan 18, 2007 8:45 pm    Post subject: Re: sub-properties events Reply with quote



Hallo,
have you solved your problem, or ist it still exists?
Maybe i can help you.

erich

PlutoPlanet schrieb:
Quote:
Hello World

I wrote a component (MyComponent) that contains a TSQLConnection as
subproperty.

property MyConnection: TSQLConnection read FConnection write
SetMyConnection;

To be informed when a connection is being established I did the
following:

procedure TMyComponent.SetMyConnection( Value: TSQLConnection )
begin
if Value <> nil then
begin
Self.MyConnection.AfterConnect := Self.HandleConnect;
end;
end;

procedure TMyComponent.HandleConnect( Sender: TObject )
begin
// do some stuff
end;

This works pretty good as long as there is a TSQLConnection connected
with only one TMyComponent.
As soon as I have 2 or more TMyComponents connected with the same
TSQLConnection it doesn't work anymore because the TSQLConnection's
AfterConnect only points to the last one beeing selected within
TMyComponent.
What is the right way getting notified about events of sub-properties?

Thanks,
Herwig
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Writing All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.