Regions / Multiple Winforms

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

Regions / Multiple Winforms
 
Emmanuel SELLIER




Posts: 23
Joined: 2016-11-23
Hello,

Question1:
I'm trying to set an Outlook Region in which I'd like to change the winform depending of concept.

For now, I've created two different regions with two distinct class names.
I would like to be able to programmatically hide one and display an other.

But... if the user closes the region, it seems the form is disposed and GetCurrentForm() will return null.
I then instanciate a new winform and then set the regionState to Normal.
But even if I instantiate a new Form, it not affected to the region... then how could I do that?

If you have any other idea how to do a such thing... I would be very pleased to know.

My code:
public void showRegionByName(string regionName, bool visible)
        {
            for (int i = 0; i < this.regionsFormsManager.Items.Count; i++) {
                if (this.regionsFormsManager.Items[i].FormClassName == this.AddinName+"."+regionName)
                {
                    showRegion(this.regionsFormsManager.Items[i].GetCurrentForm(), regionName, true);
                }
                else
                {
                    //this.regionsFormsManager.Items[i].Enabled = false;
                    showRegion(this.regionsFormsManager.Items[i].GetCurrentForm(), null, false);
                }
            }
        }

        private AddinExpress.OL.ADXOlForm createForm(string className)
        {
            AddinExpress.OL.ADXOlForm frm = null;
            switch (className)
            {
                case "view1":
                    frm = new view1Class();
                    break;
                case "view2":
                    frm = new view2Class();
                    break;
            }
            if (frm != null)
                frm.Enabled = true;
            return frm;
        }

        public void showRegion(AddinExpress.OL.ADXOlForm frm, string className,  bool visible)
        {
            if (frm == null && visible == true && className != null)
            {
                frm = createForm(className);
            }
            if (frm == null)
                return;

            if (visible == true)
            {
                frm.RegionState = AddinExpress.OL.ADXRegionState.Normal;
                frm.Visible = true;
            }
            else
            {
                frm.RegionState = AddinExpress.OL.ADXRegionState.Hidden;
                frm.Visible = false;
            }
        }


Question 2:
Even if the region initial state is set to Hidden.
When Outlook starts, all the regions are displayed.
How can I set the regions to be hidden on start? (other than hiding the regions when addin initializes).

Thanks
Posted 26 Mar, 2019 12:08:24 Top
Alexander Solomenko




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

I will email you an example that shows how to manage the visibility of forms both at startup and while working with Outlook. Also, please note that the visibility and state of the form can be controlled in the ADXBeforeFormShow event, depending on the context. As for question 2, if you meant the DefaultRegionState property, it works only on the first start. On subsequent starts, the region will restore its last state.
Regards,
Aleksandr Solomenko
Posted 27 Mar, 2019 08:17:17 Top