Hiding CommandBars

Add-in Express™ Support Service
That's what is more important than anything else

Hiding CommandBars
 
Eric Legault


Eric Legault


Posts: 67
Joined: 2009-01-27
Me again! :-)

Is there a trick to hiding ADXOlInspectorCommandBar objects? I have one defined for Outlook 2003 that's for ItemTypes = Mail. I want to hide them for read messages, show them for compose messages. The states for Visible and Enabled are True by default.

I'm trying all of the following:

- adxOutlookEvents.NewInspector: Set myAdxOlInspectorCommandBar.Visible = False
- adxOutlookEvents.InspectorAddCommandBars: Set myAdxOlInspectorCommandBar.Visible = False

AND in the above events, I call ToggleOutlookToolbarVisibleState as a backup, which does:

Dim olToolbar As Object = Nothing

olToolbar = Me.FindCommandBarObj(AdxOlInspectorCommandBarCSPF.CommandBarName)
If Not (olToolbar Is Nothing) Then olToolbar.Visible = Show

What's happens above is that FindCommandBarObj returns Nothing!

And the end result is my toolbar is always visible. All I can do is disable buttons instead.

What could I be doing wrong? (BTW, this has nothing to do with my WordMail/Word toolbars issue)
Eric Legault [MVP - Outlook]
About: http://about.me/ericmlegault
Posted 26 Aug, 2010 23:02:38 Top
Alexander Solomenko




Posts: 140
Joined: 2009-02-27
Hi Eric,

In the InspectorAddCommandBars event some commandBars can be not created yet. That is why the FindCommandBarObj function returns Nothing.
I have another idea. Try to use the existing CommandBar (with already exist) and to read the state of any of its controls. For example, some buttons can be visible or invisible in different types of inspector (Read / Compose).
Regards,
Aleksandr Solomenko
Posted 30 Aug, 2010 07:15:24 Top
Eric Legault


Eric Legault


Posts: 67
Joined: 2009-01-27
Thanks Aleksandr. That's what I'm doing currently - disabling buttons based on the Inspector types. But my client wants the bar hidden completely, which is what I'm trying to do.

Note that I'm using FindCommandBarObj during NewInspector and Inspector_Activate as well. Would that function fail in those events? If so, is there any event that can be trapped before the message is displayed that can hide a toolbar?
Eric Legault [MVP - Outlook]
About: http://about.me/ericmlegault
Posted 30 Aug, 2010 10:30:45 Top
Alexander Solomenko




Posts: 140
Joined: 2009-02-27
Hi Eric,

As I have already mentioned, at the moment when these events occur some Command bars can be absent and the FindCommandBarObj function will return null.
Please give a step-by-step description of a Command Bar you are looking for or send us a test project which shows the problem.
Regards,
Aleksandr Solomenko
Posted 31 Aug, 2010 09:33:36 Top
Eric Legault


Eric Legault


Posts: 67
Joined: 2009-01-27
Thanks Aleksandr. I am able to call FindCommandBarObj during Inspector_Activate, so I am able to hide it successfully now.

One other thing: the toolbar is created in the AddinModule designer with the Temporary property set to True. If Outlook is loaded without this add-in, the toolbar is still visible. Shouldn't ADX's internal framework be deleting these toolbars as well on Explorer or Inspector Close? Or is that something developers have to do manually?
Eric Legault [MVP - Outlook]
About: http://about.me/ericmlegault
Posted 31 Aug, 2010 14:52:47 Top
Andrei Smolin


Add-in Express team


Posts: 18830
Joined: 2006-05-11
Hi Eric,

Toolbars having Temporary = True are deleted (or, better yet, they are not saved) when you close the host application. For Outlook this is the recommended setting.

Since the toolbar is visible, there are two possibilities:
- Temporary is set to false somewhere in your code; you can check if this is the case by adding a check in AddinInitialize
- the toolbar was made permanent at some stage. In this case, you can just remove it in Tools | Customize.


Andrei Smolin
Add-in Express Team Leader
Posted 01 Sep, 2010 07:56:21 Top
Eric Legault


Eric Legault


Posts: 67
Joined: 2009-01-27
Thanks Andrei. Your logic makes sense. The Temporary property WAS set to False, so perhaps it's continued presence was an artifact of the test machine after it was changed to True.
Eric Legault [MVP - Outlook]
About: http://about.me/ericmlegault
Posted 01 Sep, 2010 10:58:09 Top