How to ADXOlForms visible (ADXOlFormsCollectionItem.Enabled = true)

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

How to ADXOlForms visible (ADXOlFormsCollectionItem.Enabled = true)
 
Markus Welker


Guest


Hi,

I'm using an ADXOlForm in the bottom of the navigator panel.
I want to enable/disable the form by using a button in the Outlook main menu.

Since I don't want to just show/hide the form, but actually want to dispose the instance on a disable request, I use the ADXOlFormsCollectionItem.Enabled property.

Works perfectly for ADXOlFormsCollectionItem.Enabled = false...
but ADXOlFormsCollectionItem.Enabled = true does not make ADX to create the forms again. The user has manually to switch to another folder to make it appear again. And he as to do it for each open Explorer-windows separatly.

I tried to do a programmatically folder switch, but that does not work well: Sometimes it works fine, sometimes not. Sometimes it works for the non active Explorer-windows, but not for the active Explorer-window.

What can I do?

Thanks for your help!




Here is the code.
ItemId is just a class wrapping an Outlook id.
ComRelease just releases the COM object in its Dispose method.




        internal static void ReselectFolders(_Application application, NameSpace nameSpace)
        {
            Microsoft.Office.Interop.Outlook.Explorers explorers = application.Explorers;
            using (new ComReleaser(explorers))
            {
                if (explorers != null)
                {
                    MAPIFolder inbox = nameSpace.GetDefaultFolder(OlDefaultFolders.olFolderInbox);
                    using (new ComReleaser(inbox))
                    {
                        if (inbox != null)
                        {
                            ItemId inboxId = new ItemId(inbox);
                            MAPIFolder sentMail = nameSpace.GetDefaultFolder(OlDefaultFolders.olFolderSentMail);
                            using (new ComReleaser(sentMail))
                            {
                                if (sentMail != null)
                                {
                                    int count = explorers.Count;
                                    for (int i = 0; i < count; i++)
                                    {
                                        object explorerObj = OutlookUtilities.GetItem(explorers, i);
                                        using (new ComReleaser(explorerObj))
                                        {
                                            if (explorerObj is Explorer)
                                            {
                                                Explorer explorer = (Explorer)explorerObj;

                                                MAPIFolder current = explorer.CurrentFolder;
                                                using (new ComReleaser(current))
                                                {
                                                    if (current == null || !ItemId.IsEqual(new ItemId(current), inboxId))
                                                    {
                                                        explorer.SelectFolder(inbox);
                                                    }
                                                    else
                                                    {
                                                        explorer.SelectFolder(sentMail);
                                                    }
                                                    System.Windows.Forms.Application.DoEvents();
                                                    object o = new object();
                                                    lock (o)
                                                    {
                                                        Monitor.Wait(o, Constants.OutlookFolderReselectTime);
                                                    }
                                                    System.Windows.Forms.Application.DoEvents();

                                                    if (current != null)
                                                    {
                                                        explorer.SelectFolder(current);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Posted 12 Apr, 2007 07:27:00 Top
Fedor Shihantsov


Guest


Hi Markus,

We will provide the ADXOlFormsCollectionItem.ApplyTo(object ExplorerOrInspectorObj) method to simplify the task. I think it will be available in the release planned for May, 1.

P.S. Note that we take up your forum requests in the order we receive them.
Besides, it may take us some time to investigate your issue. Please be sure we will let you know as soon as the best possible solution is found.
Posted 13 Apr, 2007 06:25:30 Top