Active Custom Tab outside of AddInStartupComplete

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

Active Custom Tab outside of AddInStartupComplete
 
Ryan Keeter




Posts: 10
Joined: 2015-07-07
In the AddInStartupComplete, I can get an access to the IRibbonUI by capturing that variable from the OnRibbonLoaded event. At that specific time, I can change the focus of ribbon to my custom tabe (see code below in figure 1). The question is, how do I change the focus of the current tab an ANY time...not just at addInStartupComplete. For example, how do I just hit a button and force a tab focus shift? Please see code in figure 2 below that doesn't work.

figure 1:

public IRibbon Ribbon {get;set;}
private void AddinModule_AddinStartupComplete(object sender, EventArgs e)
{
   this.OnRibbonLoaded += AddinModule_OnRibbonLoaded;
            
}
private void AddinModule_OnRibbonLoaded(object sender, IRibbonUI ribbon)
{
   this.Ribbon = ribbon;
   ribbon.ActivateTab(adxRibbonTab1.Id); //this works
            
}


figure 2(does not work, but I feel like it should):


private void adxOutlookAppEvents1_ExplorerFolderSwitch(object sender, object explorer)
{
    Outlook._Explorer ae = OutlookApp.ActiveExplorer();
           
    var fullFolderPath = ae.CurrentFolder.FullFolderPath;
    if (fullFolderPath.Contains("Tracker Tools"))
    {
        this.ActivateRibbonTab(adxRibbonTab1.Id); //doesn't work
    }
    Marshal.ReleaseComObject(ae);
}
Posted 21 Sep, 2015 20:19:13 Top
Andrei Smolin


Add-in Express team


Posts: 14140
Joined: 2006-05-11
Hello Ryan,

Try adxRibbonTab1.Activate().

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 22 Sep, 2015 04:11:50 Top
Ryan Keeter




Posts: 10
Joined: 2015-07-07
Andrei,

Thank you for the quick response. I tried the solution you mentioned, and it did not work. I have tried activating the tab from the IRibbonUI, from the control itself as you mentioned, and ADXAddinModule.ActivateRibbonTab(). There has to be a way to do this, this seems like basic functionality. You hit on "inbox" and the ribbon changes to reflect "inbox" actions. I want to hit on my solution module and have the ribbon reflect options to act upon my solution module items. How can this be done from the ExplorerFolderSwitch event?

Is the answer just moving the tab to the first position, before "home"? And maybe it activates, then move it back to the last position later?

Thank you so much for your time.
Posted 22 Sep, 2015 07:01:46 Top
Andrei Smolin


Add-in Express team


Posts: 14140
Joined: 2006-05-11
Ryan,

Does this work if called from the Click event of a Ribbon button?

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 22 Sep, 2015 07:34:07 Top
Ryan Keeter




Posts: 10
Joined: 2015-07-07
@Andrei: I created a second adxRibbonTab and added a button, and on the click event I put the code: IRibbonUI.Activate(control.Id). When I click it, the tab I wanted activated is activated.

I can activate a tab in the "onclick" event, but not the explorer folder switch event. This confuses me. I want to show the tab when the solution module folder is clicked...how do I do that?
Posted 22 Sep, 2015 17:17:50 Top
Ryan Keeter




Posts: 10
Joined: 2015-07-07
I was able to do a "SendKeys.Send()" function in the explorer switch event, but this is awkward. Of course, it requires me to set "ALT+T" as the keytip in the adxRibbonTab. Please see the code below. Again, I am still confused as to why I lose the IRibbonUI in the explorer switch event.


 private void adxOutlookAppEvents1_ExplorerFolderSwitch(object sender, object explorer)
        {

            Outlook._Explorer ae = OutlookApp.ActiveExplorer();

            var fullFolderPath = ae.CurrentFolder.FullFolderPath;
            if (fullFolderPath.Contains("Tracker Tools"))
            {
                unitOptionsRibbonGroup.Visible = true;
                Timer tmr = new Timer();
                tmr.Interval = 400;
                tmr.Tick += delegate(object s, EventArgs e)
                {
                    SendKeys.Send("%(T)%");
                    tmr.Stop();
                };
                tmr.Start();

            }
            Marshal.ReleaseComObject(ae);
        }
Posted 22 Sep, 2015 18:38:05 Top
Andrei Smolin


Add-in Express team


Posts: 14140
Joined: 2006-05-11
Ryan,

Ryan Keeter writes:
I want to show the tab when the solution module folder is clicked...how do I do that?


In the ExplorerFolderSwitch event you can start a timer (System.Windows.Forms.Timer) or use the SendMessage method and OnSendMessage event, see section Wait a little at https://www.add-in-express.com/docs/net-office-tips.php#wait-a-little. This creates a delay that lets Outlook redraw the Ribbon; calling ADXRibbonTab.Activate() after the delay will work (like if you click a Ribbon button).

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 23 Sep, 2015 03:32:28 Top
Ryan Keeter




Posts: 10
Joined: 2015-07-07
@Andrei:

The "sendMessage" method and subsequently raised event doesn't work, it's too fast (code below). I can use a timer, but the "Home" tab is still shown for a split second and then the timer fires and the tab changes. How do I stop the "Home" tab from displaying altogether? How do I cancel the Mso tab switch?


code from sendMessage method mentioned above:

const int Message = (0x0400) + 1000;
        private void adxOutlookAppEvents1_ExplorerFolderSwitch(object sender, object explorer)
        {

           
            this.SendMessage(Message);
            this.OnSendMessage += AddinModule_OnSendMessage;
           
        }

        private void AddinModule_OnSendMessage(object sender, ADXSendMessageEventArgs e)
        {
            if (e.Message == Message)
            {
                Outlook._Explorer ae = OutlookApp.ActiveExplorer();

                var fullFolderPath = ae.CurrentFolder.FullFolderPath;
                if (fullFolderPath.Contains("Tracker Tools"))
                    adxRibbonTab1.Activate();

                Marshal.ReleaseComObject(ae);
            }
        }
Posted 23 Sep, 2015 05:24:46 Top
Andrei Smolin


Add-in Express team


Posts: 14140
Joined: 2006-05-11
Ryan Keeter writes:
How do I stop the "Home" tab from displaying altogether? How do I cancel the Mso tab switch?


The Outlook/Office object model doesn't provide an event that you could use to achieve this.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 23 Sep, 2015 07:27:32 Top