John W. Colby
jwcolby at colbyconsulting.com
Thu Jan 15 18:02:06 CST 2004
Yes, please send. And if that's a 135, then I never get above about a 20 or so. ;-) Thanks, John W. Colby www.ColbyConsulting.com -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Ken Ismert Sent: Thursday, January 15, 2004 6:40 PM To: 'Access Developers discussion and problem solving' Subject: RE: [AccessD] Implements vs WithEvents >One thing you say intrigues me though. You mention Implements allowing a >custom callback scheme and sending messages. How does this work? How does >the callback communicate between class instances? John, Interesting, the difference in perspectives: after your experience with true object languages, you find VBA limiting, while I cut my teeth on non-object languages, and find Implements a revelation. I'd love to work in a true OOP language that supports inheritance, but feel it would take some time to fully grasp its power and use it effectively. The callback scheme can be summarized as follows: 1. The callbacks are defined as methods in the ICallback interface: ' Insert this code in Class module ICallback Public Sub Message(sBody As Text) End Sub 2. Class CWannaMessage, wanting to receive messages, implements ICallback: Implements ICallback Private Sub ICallback_Message(sBody As Text) Debug.Print sBody End Sub 3. The CWannaMessage object makes a CCaller object, and passes a reference to itself: Set rCaller = New CCaller rCaller.Setup Me 4. CCaller's setup code looks like this: Private mrCallback as ICallback Public Sub Setup(CallbackObj As ICallback) Set mrCallback = CallbackObj End Sub 5. When CCaller wants to send a message: mrCallback.Message "Hello, you!" 6. Since you now have circular object references, CCaller must also provide a way to release its callback reference: Public Sub Shutdown Set mrCallback = Nothing End Sub 7. CWannaMessage must shutdown its caller when it isn't needed, or neither object will terminate: rCaller.Shutdown This example shows a one-on-one conversation, but it could easily be extended for multiple callers. CWannaMessage could maintain a collection of CCallers, and pass each CCaller its name or index on Setup, which CCaller could then pass back when it sends its Message. Or CCaller could just pass a reference to itself (Me) back to CWannaMessage. In any case, ICallback would have to be suitably extended. I calculate the obtuseness of this post at 135 degrees, a 5 degree improvement over the last. -Ken ps: I have some relatively simple form management code using interfaces. It allows a Parent form to open a Child, and be notified when it closes. I'll send you it if you're interested. _______________________________________________ AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com