Hello Ilia,
I have placed our HostClass sample on our ftp site
ftp://ftp.summsoft.com/vba/hostclassexample.zip
This example is intended to demonstrate the use of VBA host classes.
Full implementation of VBA host classes is quite involved, requiring that
you respond to a number of events. Without this example, getting all the
pieces to cooperate requires trial and error.
The example is written in VB. The application itself is minimal, thereby
exposing the particulars of host classes in its most raw and simple form.
1. A template host class is created by calling IApcProjectItems::AddHostClass.
2. Two arrays (or VB collections) are created to hold the aggregated instances (called TheOuterInstances in the VB example) and the raw instances (called TheRawInstances).
3. When you click on the "New Doc Class" menu item, IApcInstances::Add is called to create a new instance of our given host class type. Before Add returns, an event is generated -- IApcProjectItemEvents::CreateInstance. This event handler creates a new raw instance and returns it, saving it in the TheRawInstances collection. When IApcInstances::Add finally
returns to the caller, it returns the aggregated instance which we save into the TheOuterInstances collection.
4. To raise an event, we simply iterate through the raw instances and raise the event on each instance.
5. If you hit the Reset button in VBA, you will be asked to destroy all your instances -- the IApcProjectItemEvents::ReleaseInstances event is fired. We simply destroy our two collections to release our hold on everything.
Hope this helps.
Jim G