View Single Post
  #3  
Old May 13th 09, 03:41 PM posted to microsoft.public.outlook.program_addins
[email protected]
external usenet poster
 
Posts: 23
Default Creating toolbar in new Explorer

Any Explorer opened after the initial Explorer will fire NewExplorer().
Handle that for those Explorers and use that to get the Activate() event for
that Explorer. Use unique Tag values as you would with an Inspector.

For the initial Explorer Activate() won't fire in almost all cases normally.
So you use Explorer.BeforeFolderSwitch() and Explorer.SelectionChange(). I
add handlers for all 3 events for every Explorer that gets opened, and check
a _startup flag in those events to see if UI creation is needed. If so I
create the UI and then set _startup to False. You'll find that for that
first Explorer you will get the SelectionChange() event, and therefore your
UI will be created.


Here is what I did:
inside the OnNewExplorer handler I instantiate my ExplorerWrapper
class. Within its constructor I do:

m_spExplorer-Activate(); // --- Does this ensure that all
objects get created by the time I hit the following lines?
CloseEvent:ispEventAdvise((IDispatch*)m_spExplor er);
ToolbarWrapper = new CToolbarWrapper(m_spExplorer);
m_spExplorer-get_CommandBars(&spCmdBars);
ToolbarWrapper-CreateGUI(spCmdBars);

Are there any errors in my logic? If so, then I will try going the
Activate/BeforeFolderSwitch/SelectionChange way, but I am not sure
that those handlers will be called soon enough (i.e. to ensure that
the toolbar is visible right after the explorer window pops up)
Ads