Skip Rewriting the Same Code — Standard Code, Abstraction, and a Root Interface (1 Viewer)

@eric: in your Frameworks article you write: "A form wrapper created in Form_Open() cannot sink that event because it already will have occurred. The form wrapper’s Class_Initialize() can be a viable proxy, however."
True, and yours is a fine implementation (although you're not showing it in Class_Initialize code). I do it a bit differently:
Similar to your BoundFrm property I have an Init method, taking a form reference as an argument. It sets the event handlers, and at the bottom:
'Fake the OnOpen call which has already happened.
Dim intDummy As Integer
mfrmThis_Open intDummy
I find this elegant because it follows the same pattern as other events.

As we have discussed privately, New-ing the object and calling its Init method can both be done in what's often called a Factory method. Not shown in this post.
 
@eric: As a side show, I've learned that the Implements keyword only implements an interface for methods and properties, NOT for events. Sometimes a class object may want to inform its "subscribers" that some custom event has happened. Along the same way as "observable collections" in C#. Have you run into this dilemma, and if so, how did you work around it?
If I may respond to that, I actually looked into this many years ago.
Maybe this will help you: Using events together with interfaces in vba
 

Users who are viewing this thread

Back
Top Bottom