Persist toolbar visible state

  • Thread starter Thread starter Saeed
  • Start date Start date
S

Saeed

I have added few buttons in a new toolbar using VSTO 2005, which I add during
the add-in startup. User can set its visibility using customize>toolbars. I
want to persist the state of toolbar i.e. if Outlook is closed when toolbar
was not visible, the toolbar should not be visible on next startup. For doing
this I am trying to keep the state of toolbar visibility in registry. Is
there an event of closing the outlook when I can read the state of toolbar
visibility and save it in registry? Add-in shutdown does not work as the
explorers are closed by that time.

Is there an standard way of doing this I mean not through registry?
 
You can persist the settings anywhere you want, for example in the user
settings for the addin or the registry or a file stored somewhere, that's up
to you.

Handle the Explorer.Close() event and get the visibility in that event
handler.
 
Thanks Ken. Can you please give me fully qualified namesapce for class
Explorer which you have mentioned. I could not find any class which provides
Close as event. I am using VSTO 2005 with C#.
 
Where you have overloaded names such as the Close() method and the Close()
event you can usually use something like ExplorerEvents. I'd add that event
handler in C# using code something like this:

((Outlook.ExplorerEvents_Event)_expl).Close += new
Outlook.ExplorerEvents_CloseEventHandler(ExplClose);

_expl is an Explorer object declared at class level.
 
Hi Ken,
I am able to get the event now. But the problem is not solved because by the
time of this event active explorer is closed and I do not get reference to
the toolbar to check if it was visible last time or not. Is there any event
for the case when use clicks customize toolbar and enables or disables any
toolbar. My whole aim is to keep my toolbar visibility as previous case i.e.
before outlook was closed.
 
The Close() event should not be firing after the Explorer is already closed.
Your toolbar reference should be in place long before that event, you should
be getting and maintaining it when you create the UI.
 
Back
Top