A different 'AddinExpress.OL.ADXOlForm' per Inspector

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

A different 'AddinExpress.OL.ADXOlForm' per Inspector
 
Romain Vergnory




Posts: 20
Joined: 2014-02-17
I'm trying to display an 'AddinExpress.OL.ADXOlForm' for several opened outlook.appointment inspector.

If I open one, everything is fine. If I try opening another, the first one becomes blank : more precisely, the 'OnControlRemoved' event is raised, and my form is displayed somewhere else (its parent changed probably?), namely the second inspector.

As far as I can guess, this is due to the structure of the AddInModule. I'm thinking that, instead of having my form nicely named and generating a member for the AddInModule, I should 'programatically' redesign one everytime a new inspector is opened, but I'm expecting you guys have design a better, faster, stronger method for this ?
Posted 26 Feb, 2014 11:12:52 Top
Andrei Smolin


Add-in Express team


Posts: 18829
Joined: 2006-05-11
Hello Romain,

Could you please send me a fragment of the InitializeComponent method from your add-in module describing the settings of the corresponding ADXOlFromsCollectionItem? Also please specify the Outlook version, service pack and bitness used. And Add-in Express build number please.

I'm going to reproduce this in order to understand what occurs.


Andrei Smolin
Add-in Express Team Leader
Posted 27 Feb, 2014 05:20:50 Top
Romain Vergnory




Posts: 20
Joined: 2014-02-17
Hello,

Thanks for your answer. I hope you find anything useful.
I'm guessing from your answer that it's the opposite of the default behaviour ? And that each form should normally behave as I expected ?


using System;
using System.Runtime.InteropServices;
using System.ComponentModel;
using System.Windows.Forms;
using AddinExpress.MSO;
using Outlook = Microsoft.Office.Interop.Outlook;
using UrbaAddInOutlook.Controls;
using UrbaAddInOutlook.Forms;

namespace UrbaAddInOutlook
{
    /// <summary>
    ///   Add-in Express Add-in Module
    /// </summary>
    [GuidAttribute("B7515951-C4F8-44ED-9598-DD09B15EE2FB"), ProgId("UrbaOutlookAddIn2.AddinModule")]
    public class AddinModule : AddinExpress.MSO.ADXAddinModule
    {
        public AddinModule()
        {
            Application.EnableVisualStyles();
            InitializeComponent();

            // Please add any initialization code to the AddinInitialize event handler
			adxOutlookEvents.Startup += new EventHandler(Startup);
        }

		void Startup(object sender, EventArgs e)
		{
			//http://stackoverflow.com/questions/566437/http-post-returns-the-error-417-expectation-failed-c
			System.Net.ServicePointManager.Expect100Continue = false;

			adxOutlookEvents.ExplorerSelectionChange += new ADXOlExplorer_EventHandler(ExplorerEvents.SelectionChange);
			adxOutlookEvents.ExplorerBeforeItemCopy += new ADXHostAction_EventHandler(ExplorerEvents.BeforeItemCopy);
			adxOutlookEvents.ExplorerBeforeItemPaste += new ADXOlExplorerBeforeItemPaste_EventHandler(ExplorerEvents.BeforeItemPaste);
			adxOutlookEvents.ExplorerBeforeFolderSwitch += new ADXOlExplorerBeforeFolderSwitch_EventHandler(ExplorerEvents.BeforeFolderSwitch);
			ItemEvents = new ItemsEvents(this);

			//authentification
			AuthentificationControls.AuthentificationWorker.RunWorkerAsync();

			FormsManager.ADXBeforeFormInstanceCreate += new AddinExpress.OL.ADXOlFormsManager.BeforeFormInstanceCreate_EventHandler(FormsManager_ADXBeforeFormInstanceCreate);

		}

		void FormsManager_ADXBeforeFormInstanceCreate(object sender, AddinExpress.OL.BeforeFormInstanceCreateEventArgs args)
		{
			if (args.Item.FormClassName == "UrbaAddInOutlook.Forms.ADXForm")// this is an almost empty AddinExpress.OL.ADXOlForm
			{
				var inspector = args.InspectorObj as Outlook._Inspector;
				if (inspector != null)
				{
					var item = inspector.CurrentItem as Outlook.AppointmentItem;
					var _session = Sessions.State.GetOrAdd(item);
					args.Cancel = _session.resa.IsReadOnly();
					_session.IsAboutToBeDisplayed = !args.Cancel;
				}
			}
		}
		private ADXOutlookAppEvents adxOutlookEvents;
		private AddinExpress.OL.ADXOlFormsManager FormsManager;
		private AddinExpress.OL.ADXOlFormsCollectionItem MainForm;
	
		public ItemsEvents ItemEvents { get; private set; }

 
        #region Component Designer generated code
        /// <summary>
        /// Required by designer
        /// </summary>
        private System.ComponentModel.IContainer components;
 
        /// <summary>
        /// Required by designer support - do not modify
        /// the following method
        /// </summary>
        private void InitializeComponent()
        {
			this.components = new System.ComponentModel.Container();
			System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AddinModule));
			this.adxOutlookEvents = new AddinExpress.MSO.ADXOutlookAppEvents(this.components);
			this.FormsManager = new AddinExpress.OL.ADXOlFormsManager(this.components);
			this.MainForm = new AddinExpress.OL.ADXOlFormsCollectionItem(this.components);
			// 
			// FormsManager
			// 
			this.FormsManager.Items.Add(this.MainForm);
			this.FormsManager.VisualStyle = AddinExpress.OL.ADXOlVisualStyle.Office2007Plus;
			this.FormsManager.SetOwner(this);
			// 
			// MainForm
			// 
			this.MainForm.Cached = AddinExpress.OL.ADXOlCachingStrategy.None;
			this.MainForm.FormClassName = "UrbaAddInOutlook.Forms.ADXForm";
			this.MainForm.InspectorItemTypes = ((AddinExpress.OL.ADXOlInspectorItemTypes)((AddinExpress.OL.ADXOlInspectorItemTypes.olAppointment | AddinExpress.OL.ADXOlInspectorItemTypes.olMeetingRequest)));
			this.MainForm.InspectorLayout = AddinExpress.OL.ADXOlInspectorLayout.InspectorRegion;
			this.MainForm.InspectorMode = AddinExpress.OL.ADXOlInspectorMode.Compose;
			this.MainForm.IsHiddenStateAllowed = false;
			this.MainForm.IsMinimizedStateAllowed = false;
			this.MainForm.RegionBorder = AddinExpress.OL.ADXRegionBorderStyle.None;
			this.MainForm.RestoreFromMinimizedState = true;
			// 
			// AddinModule
			// 
			this.AddinName = "Urba Outlook Add In : express";
			this.Description = "Urba Outlook Add In : express";
			this.RegisterForAllUsers = true;
			this.SupportedApps = AddinExpress.MSO.ADXOfficeHostApp.ohaOutlook;

        }
        #endregion
 
        #region Add-in Express automatic code
 
        // Required by Add-in Express - do not modify
        // the methods within this region
 
        public override System.ComponentModel.IContainer GetContainer()
        {
            if (components == null)
                components = new System.ComponentModel.Container();
            return components;
        }
 
        [ComRegisterFunctionAttribute]
        public static void AddinRegister(Type t)
        {
            AddinExpress.MSO.ADXAddinModule.ADXRegister(t);
        }
 
        [ComUnregisterFunctionAttribute]
        public static void AddinUnregister(Type t)
        {
            AddinExpress.MSO.ADXAddinModule.ADXUnregister(t);
        }
 
        public override void UninstallControls()
        {
            base.UninstallControls();
        }

        #endregion

        public static new AddinModule CurrentInstance 
        {
            get
            {
                return AddinExpress.MSO.ADXAddinModule.CurrentInstance as AddinModule;
            }
        }

        public Outlook._Application OutlookApp
        {
            get
            {
                return (HostApplication as Outlook._Application);
            }
        }
    }
}
Posted 27 Feb, 2014 06:40:50 Top
Andrei Smolin


Add-in Express team


Posts: 18829
Joined: 2006-05-11
Romain,

Your description of the issue was suspicious to me: I supposed you've run into a bug in Add-in Express. However, I'm unable to reproduce the issue using an add-in minimized to just showing the form with the settings below:

            this.adxOlFormsCollectionItem1.FormClassName = "MyAddin35.ADXOlForm1";
            this.adxOlFormsCollectionItem1.InspectorItemTypes = ((AddinExpress.OL.ADXOlInspectorItemTypes)((AddinExpress.OL.ADXOlInspectorItemTypes.olAppointment | AddinExpress.OL.ADXOlInspectorItemTypes.olMeetingRequest)));
            this.adxOlFormsCollectionItem1.InspectorLayout = AddinExpress.OL.ADXOlInspectorLayout.InspectorRegion;
            this.adxOlFormsCollectionItem1.InspectorMode = AddinExpress.OL.ADXOlInspectorMode.Compose;
            this.adxOlFormsCollectionItem1.IsHiddenStateAllowed = false;
            this.adxOlFormsCollectionItem1.IsMinimizedStateAllowed = false;
            this.adxOlFormsCollectionItem1.RegionBorder = AddinExpress.OL.ADXRegionBorderStyle.None;
            this.adxOlFormsCollectionItem1.RestoreFromMinimizedState = true;


I tested this in Outlook 2013 32bit.

Please check if the issue is reproducible with such a minimized add-in. I'd like to stress: the minimized add-in project doesn't contain any other code.


Andrei Smolin
Add-in Express Team Leader
Posted 27 Feb, 2014 08:09:17 Top
Romain Vergnory




Posts: 20
Joined: 2014-02-17
Hello,

It was indeed a bug from my part : I was disposing my form myself..

I still have another question thus :
I use to use the Appointment class, but now that I migrated to ADX, I mostly use the _Appointment interface.
And apparently, the GlobalAppointmentID Property is null for new _Appointment, when this is not the case for Appointment (this was the reason for the previous bug).

I wonder, is there any other main difference I should know about when using _Appointent instead of Appointment ?
Posted 28 Feb, 2014 03:00:37 Top
Andrei Smolin


Add-in Express team


Posts: 18829
Joined: 2006-05-11
Hello Romain,

Romain Vergnory writes:
is there any other main difference I should know about when using _Appointent instead of Appointment ?


I regard them as follows: AppointmentItem = _AppointmentItem + events.

Romain Vergnory writes:
the GlobalAppointmentID Property is null for new _Appointment, when this is not the case for Appointment


This isn't so for me in Outlook 2013. The code below shows the property isn't empty:


private void adxRibbonButton1_OnClick(object sender, IRibbonControl control, bool pressed) {
    Outlook.AppointmentItem appt = OutlookApp.CreateItem(Outlook.OlItemType.olAppointmentItem) as Outlook.AppointmentItem;
    if (appt.GlobalAppointmentID == null)
        MessageBox.Show("null");
    else if (appt.GlobalAppointmentID == "") {
        MessageBox.Show("empty");
    } else {
        MessageBox.Show("other");
        MessageBox.Show(appt.GlobalAppointmentID.ToString());
    }
}

private void adxRibbonButton2_OnClick(object sender, IRibbonControl control, bool pressed) {
    Outlook._AppointmentItem appt = OutlookApp.CreateItem(Outlook.OlItemType.olAppointmentItem) as Outlook._AppointmentItem;
    if (appt.GlobalAppointmentID == null)
        MessageBox.Show("null");
    else if (appt.GlobalAppointmentID == "") {
        MessageBox.Show("empty");
    } else {
        MessageBox.Show("other");
        MessageBox.Show(appt.GlobalAppointmentID.ToString());
    }
}



Andrei Smolin
Add-in Express Team Leader
Posted 28 Feb, 2014 07:11:40 Top