I’m working on a component which works with a database, and the database connection is specified from the outside of this component via a TADOConnection property, visible in the Object Inspector. I assume that the outside user may intend to make use of the events of this ADO component. Yet, I also need to be able to detect when it connects or disconnects, and other various events. Can I get the events of the TADOConnection without overriding event handlers that an outside user may have assigned?
I’m working on a component which works with a database, and the database connection
Share
There is no solution for this without heavy side effects and/or strict limitations.
You have to reroute the events, but …
Outside users can modify events at design time (that could be handled in a way) but also at runtime and every approach will break.
As a (maybe) possible workaround (and it is a limitation) you can publish an own descent from TADOConnection and force outside users to use this, and implement multi cast events.
If you just want to get informed to Connect/Disconnect Events, you may call the protected method TCustomConnection.RegisterClient (unit Data.DB)