OnSelectionChange - Explorer window event not being captured

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

OnSelectionChange - Explorer window event not being captured
 
This forum has moved to a new location. From now on, please post all your questions about Add-in Express Regions on .NET and VSTO forum.
Stephen King




Posts: 12
Joined: 2012-05-30
I am very new to this product so forgive me if this is something obvious.

I have created a Plug-in built a very simple form and have onInitialize have the following:
ADXOlForm1Item = new ADXOlFormsCollectionItem();
            ADXOlForm1Item.ExplorerLayout = ADXOlExplorerLayout.RightReadingPane;
            ADXOlForm1Item.ExplorerItemTypes = ADXOlExplorerItemTypes.olAppointmentItem;
            ADXOlForm1Item.InspectorLayout = ADXOlInspectorLayout.RightSubpane;
            ADXOlForm1Item.InspectorItemTypes = ADXOlInspectorItemTypes.olAppointment
                | ADXOlInspectorItemTypes.olMeetingRequest | ADXOlInspectorItemTypes.olMeetingResponsePositive;
            ADXOlForm1Item.AlwaysShowHeader = true;
            ADXOlForm1Item.UseOfficeThemeForBackground = true;
            ADXOlForm1Item.FormClassName = typeof(ADXOlForm1).FullName;


The form shows up where it is suppose to show.
In the thisaddin.cs I have the following code lifted directly from the example, it also uses the outlookhelper.cs from the example project.

private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {

            #region Add-in Express Regions generated code - do not modify

            this.FormsManager = AddinExpress.OL.ADXOlFormsManager.CurrentInstance;
            this.FormsManager.OnInitialize +=
                new AddinExpress.OL.ADXOlFormsManager.OnComponentInitialize_EventHandler(this.FormsManager_OnInitialize);
            this.FormsManager.Initialize(this);

            #endregion

            _explorersManager = new OutlookHelper.ExplorersHelper(this.Application.Explorers);
            _explorersManager.SelectionChange += OnSelectionChange;
        }
 private OutlookHelper.ExplorersHelper _explorersManager = null;

        private void OnSelectionChange(OutlookHelper.ExplorerHelper explorerHelp)
        {
            Debug.WriteLine("DoSelectionChange");
            Outlook.Selection selection = explorerHelp.Explorer.Selection;
            try
            {
                if (selection.Count > 0)
                {
                    Debug.WriteLine("DoSelectionChange > 0");
                }
            }
            finally
            {
                if (selection != null)
                {
                    Marshal.ReleaseComObject(selection);
                    selection = null;
                }
            }
        }


When i change items in the explorer window, the event isn't fired.
Thanks for any help.
-Stephen
Posted 30 May, 2012 10:17:54 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Stephen,

Where did you get the ExplorersHelper class? Does it come from Add-in Express?

Please note that you develop a VSTO based add-in project and the issue relates to the Outlook Object Model. The Add-in Express support service policies section of our web site states the following:

Please note that we do not provide support for issues and questions related to the Office object model for the Add-in Express Regions for Microsoft Outlook and VSTO and Security Manager for Outlook products.
.NET, Extended MAPI, Windows Phone & RT
Posted 30 May, 2012 10:31:22 Top
Stephen King




Posts: 12
Joined: 2012-05-30
Eugene, I got it from the sample project which comes with add-in Express.
[drive]\Add-in Express\Add-in Express Regions for Microsoft Outlook and VSTO\Demo Projects\VS2010\CS\Outlook2010\HelloAdvOutlookFormRegion
Posted 30 May, 2012 10:41:11 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Stephen,

Thank you for pointing out the sample add-in you are referring to. I have just tested it on my PC with Outlook 2010 x64 and didn't notice anything strange on my road. The SelectionChange event is thrown and handled like a charm.

It looks like you modified the sample add-in project. I see the following code in the ThisAddIn_Startup sub:

explorersManager = new OutlookHelper.ExplorersHelper(this.Application.Explorers);
explorersManager.SelectionChange += new OutlookHelper.ExplorersHelper.SelectionChangeEventHandler(OnSelectionChange);
Outlook.Explorer activeExplorer = this.Application.ActiveExplorer();
if (activeExplorer != null)
{
    explorersManager.DoNewExplorer(activeExplorer);
}


Am I on the right avenue?
.NET, Extended MAPI, Windows Phone & RT
Posted 30 May, 2012 11:32:52 Top
Stephen King




Posts: 12
Joined: 2012-05-30
seems that i missed the line

if (activeExplorer != null)   
{   
    explorersManager.DoNewExplorer(activeExplorer);   
}  


once that was there, everything else fell into place.
Thanks,
-Stephen
Posted 30 May, 2012 11:57:11 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
You are welcome, Stephen!
.NET, Extended MAPI, Windows Phone & RT
Posted 30 May, 2012 12:24:15 Top