25 March 2009

Activate and Close Events

When an Activate or Close event occurs (on Explorer and Inspector objects), it doesn't tell you which inspector or explorer is activate or closed. Even worse, the CurrentExplorer or CurrentInspector references are the previous instance, not the newly activated instance.
Solution is as follows: when a NewExplorer or NewInspector event comes in (from the Explorers and Inspectors collections, respectively), create a wrapper object. This wrapper holds a reference to the explorer or inspector object to which you register for Activate and Close events. In your add-in you should keep a collection of the wrapper objects and register for Activate and Close events with your wrapper object which forwards the underlying explorer or inspector events. Now when an event comes in, you know which explorer or inspector it is because it is identified by the wrapper object.

No comments:

Post a Comment