Window specific Ribbon controls

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

Window specific Ribbon controls
 
Mike Medved


Guest


Doing development in C#, VS 2010. Add-in Express 2010. Currently testing on Outlook 2010

I show a custom form instead of the default email list for some mail folders.
I also show custom RIBBON bar (Outlook 2010). The items on the ribbon are shown/hidden/enabled/disabled depending on what is selected on the current window

If I open two explorer windows and select a different custom folder in each, it seems that the ribbon settings end up being shared across the two. So if a button should be enabled for the first one and disabled for the 2nd one based on the selection on each of the forms, it ends up being either enabled or disabled for both

The closest I came to getting it to work correctly is to re-specify the ribbon button status on adxOutlookEvents_ExplorerActivate event, but that is a really bad kludge. Doesn't work 100% of the time and the user still sees things change when they shouldn't be.

I know Outlook's ribbon is controled independently. How can that be setup for custom ribbon settings?

Thanks
Posted 12 Mar, 2011 17:14:55 Top
Eugene Astafiev


Guest


Hi Mike,

It looks like you need to use the PropertyChanging event of the ribbon controls. Please have a look at the following forum threads for more information:

http://www.add-in-express.com/forum/read.php?FID=5&TID=8677
http://www.add-in-express.com/forum/read.php?FID=5&TID=7595
http://www.add-in-express.com/forum/read.php?FID=5&TID=8473
Posted 13 Mar, 2011 06:29:03 Top
Mike Medved


Guest


Eugene,

Thanks for the guidence. Exactly what I needed. I do see how that works, though I am seeing some very odd inconsistencies. I want to replace the HOME tab with my own. I tried two different options, encountering two different problems:

1) SHOW/HIDE TABS - We should be able to show/hide tabs dynamically now that the bug with that is fixed (http://www.add-in-express.com/forum/read.php?FID=5&TID=8422)
And the tabs do have a PropertyChanging event.

I created a dummy tab ribbonHOMETab, set IdMso=TabMail and defined PropertyChanging event for Visible to be false when my custom form is shown. true otherwise
I created a dummy tab ribbonMYHOMETab, did NOT set IdMso and defined PropertyChanging event for Visible to be true when my custom form is shown. false otherwise

The PropertyChanging for ribbonHOMETab is not triggered at all.
The PropertyChanging for ribbonMYHOMETab is triggered and triggered and e.Value set to true but the Tab does not show.


2) Show/Hide Groups - When Option #1 failed, I tried hiding all groups on the built in tab when my custom folder is shown, and inserting my own groups within the built-in tab.

I set the PropertyChanging on all built in and custom groups and set them based on the currently displayed folder.

This is where it gets weird. The PropertyChanging gets triggered OK for all the groups the FIRST time I start Outlook. However, when I switch folders, it doesn't trigger. And the only way I can get it to trigger is to do this:

private void adxOlFormsManager_ADXBeforeFolderSwitch(....)
{
	// ribbonHOMEGroup1 refers to one of the groups on the default HOME tab
	ribbonHOMEGroup1.Visible = ribbonHOMEGroup1.Visible;
}


NOTE that the line doesn't actually change anything. It just sets the visible flag to itself. Having just that one line makes it so PropertyChanging events get fired correctly on ALL groups - both built-in ones and my own.

And that workaround only works if you touch the Visible property on one of the built-in groups, not one of the custom ones.
Posted 13 Mar, 2011 10:20:17 Top
Mike Medved


Guest


In issue #1 disregard the Property changing not triggering at all.

As for issue #2, it actually impacts both #1 and #2. Seems that touching the Visible property on any item on the default HOME group causes all the PropertyChanging events to get triggered - buttons, groups and tabs.

Is that intended? When should the Visible and Enabled PropertyChanging events get triggered?
Posted 14 Mar, 2011 11:55:54 Top
Eugene Astafiev


Guest


Hi Mike,

Could you please specify the build number of Add-in Express you use?

For more information about the Ribbon callbacks please take a look at the http://msdn.microsoft.com/en-us/library/aa338202%28v=office.12%29.aspx article.
Posted 14 Mar, 2011 12:22:24 Top
Mike Medved


Guest


version 6.3.3052.2005

Will look at the link you gave. thanks
Posted 14 Mar, 2011 12:29:43 Top
Eugene Astafiev


Guest


Hi Mike,

The following code works like a charm for built-in and custom ribbon tabs on my PC with Office 2010:

private void adxRibbonTab1_PropertyChanging(object sender, AddinExpress.MSO.ADXRibbonPropertyChangingEventArgs e)
{
   if (e.PropertyType == AddinExpress.MSO.ADXRibbonControlPropertyType.Visible)
   {
       e.Value = false;
   }
}
Posted 14 Mar, 2011 13:18:46 Top
Mike Medved


Guest


What do you consider as "working" though? that would get triggered on startup. Would that code get called again when you switch folders? I would expect the code to trigger when you switch folders, but it doesn't. Not unless I add the line to set the visible property to itself. I can give you a sample app if it will help explain the situation
Posted 14 Mar, 2011 14:00:59 Top
Mike Medved


Guest


[EDIT] ok, disregard. Seems that setting the Visible property triggered an Invalidate of the ribbon, which I would have been doing in the first place in order to have it update. I don't think I needed to do that for enabling/disabling buttons, so didn't think of that.

NOTE: In the sample I sent you I did also report an obscure situation where the HOME tab disappeared entirely. That does still happen
Posted 14 Mar, 2011 14:40:16 Top
Eugene Astafiev


Guest


Hi Mike,

Thank you for providing me with a sample add-in project. I have reproduced both issues on my PC with Office 2010.

1. Please note that Ribbon UI is a static thing from its birth. You need to use the Invalidate method of the ADXRibbonTab component to update the ribbon controls instead. You can read more about this in the http://msdn.microsoft.com/en-us/library/aa338202%28v=office.12%29.aspx article in MSDN.
2. The built-in tab may disappear sometimes. This is a bug in the Ribbon UI extensibility. I even can reproduce it with a regular VSTO add-in project. You don't need to use getVisible callback (see the Ribbon XML markup) if you set the IdMso property - just set the visible to true in that case. Also you can find the "Visible property of the ADXRibbonTab component was handled incorrectly for built-in Office ribbon tabs." entry in the http://www.add-in-express.com/news-latest.php section of our web site.
Posted 17 Mar, 2011 08:07:33 Top