Outllook Form Region

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

Outllook Form Region
I have created outlook plugin project and added one form manager and 2 form regions, one in buttomnavigationpane and another one in webviewpane. There is one treeview control in buttomnavigationpane. Every time treeview node selection change, I would like 
Soe Thu Aung




Posts: 15
Joined: 2015-04-14
I have created outlook plugin project and added one form manager and 2 form regions, one in buttomnavigationpane and another one in webviewpane. There is one treeview control in buttomnavigationpane. Every time treeview node selection change, I would like to show form in WebViewPane and show relevant data with grid. So I would like to control visibility of form in WebViewPane based on selection of treeview node in buttomnavigationpane. And also want to pass some parameter, such as selected node values to populate data in WebViewPane. May I know what is the best way implement this scenario?


[img]REMOVED[/img]
Posted 14 Apr, 2015 23:58:19 Top
Andrei Smolin


Add-in Express team


Posts: 18793
Joined: 2006-05-11
Hello Soe,

You access the instance of the from shown in the WebView pane using ADXOlFormsCollectionItem.GetForm(%an Outlook.Explorer object%). To hide the form instance, invoke ADXOlForm.Hide(); to show it, call ADXOlForm.Show(). To invoke a member that your form provides, cast the ADXOlFrom returned by ADXOlFormsCollectionItem.GetForm() to the type of your form e.g. MySuperDuperForm, and then invoke the member that MySuperDuperForm provides.

On how to create a WebViewPane form on the fly, see the following sample project: http://temp.add-in-express.com/support/TestWebViewPane2.zip.

Do I answer your questions?


Andrei Smolin
Add-in Express Team Leader
Posted 15 Apr, 2015 05:05:59 Top
Soe Thu Aung




Posts: 15
Joined: 2015-04-14
Hi Andrei Smolin,

Thanks a lot for your advise, I've managed to implement the code. Functionally it's working now. However there are 2 issues.

1. WebView is still showing when I click inbox (Is there anyway to reset webview to previous inbox folder view when my buttomnavigationpane form region is not focus)
2. Performance, screen refresh time (Every time I click treeview node, screen refresh 2 times. It's pretty obvious for user. Is there any way to improve screen refresh time?)

Regards,
Soe Thu Aung
Posted 15 Apr, 2015 20:53:13 Top
Soe Thu Aung




Posts: 15
Joined: 2015-04-14
Hi Andrei Smolin,

My apologies, I have managed to fix item 1. Please reply on item 2 only.

Regards,
Soe Thu Aung
Posted 15 Apr, 2015 21:55:23 Top
Andrei Smolin


Add-in Express team


Posts: 18793
Joined: 2006-05-11
Soe,

Please have a look at the code of http://temp.add-in-express.com/support/TestWebViewPane2.zip to show/hide the form correctly. Does it help?


Andrei Smolin
Add-in Express Team Leader
Posted 16 Apr, 2015 07:19:12 Top
Soe Thu Aung




Posts: 15
Joined: 2015-04-14
Hi Andrei Smolin,

Yes, I did exactly same as the code sample. Based on the code, there is screen refresh during setting webview to current folder (switch to outbox folder and switch back to current folder, if I'm not wrong). Is that the only way we can achieve this requirement? Any other recommendation or possible way to fine tune that?

Regards,
Soe Thu Aung
Posted 16 Apr, 2015 20:35:19 Top
Andrei Smolin


Add-in Express team


Posts: 18793
Joined: 2006-05-11
Hello Soe,

My name is Andrei, please ))

Soe Thu Aung writes:
Is that the only way we can achieve this requirement?


Yes, it is. WebViewPane bases on the MAPIFolder.WebViewUrl and MAPIFolder.WebViewOn properties. Unfortunately, applying them to the folder opened at startup doesn't work in all Outlook versions. They start working correctly only after Outlook navigates from the startup folder. This means, to set WebViewPane for the startup folder, Add-in Express has to switch to a folder (Outbox) and then switch back to the startup folder. It's really unpleasant and the operation itself isn't that simple (because all these things occur at startup) but alas, there's no other way to solve this issue.


Andrei Smolin
Add-in Express Team Leader
Posted 17 Apr, 2015 07:13:51 Top
Soe Thu Aung




Posts: 15
Joined: 2015-04-14
Hi Andrei Smolin,

Thanks for explanation.

Regards,
Soe Thu Aung
Posted 19 Apr, 2015 21:03:17 Top
Andrei Smolin


Add-in Express team


Posts: 18793
Joined: 2006-05-11
You are welcome.


Andrei Smolin
Add-in Express Team Leader
Posted 20 Apr, 2015 03:18:13 Top
Soe Thu Aung




Posts: 15
Joined: 2015-04-14
Hi Andrei Smolin,

Currently I'm facing one error in switching view. Following is the error log, this error does not occur all the times, intermittent only.
////////////////////
System.Runtime.InteropServices.InvalidComObjectException: COM object that has been separated from its underlying RCW cannot be used.
at System.Variant.MarshalHelperConvertObjectToVariant(Object o, Variant& v)
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at XXX.AddinModule.SetExplorerFolder(Explorer Explorer, MAPIFolder Folder)
////////////////////

Following is the function to switch (copied from sample you have provided before). May I know what is the reason for HostMajorVersion checking and why need to call Explorer.GetType().InvokeMember ? Is it for backward compatibility or something else? My add-in need to support only Office 2010 and above. HostMajorVersion 14 and above.
////////////////////
private void SetExplorerFolder(Outlook.Explorer Explorer, Outlook.MAPIFolder Folder)
{
try
{
if (HostMajorVersion == 9 || HostMajorVersion == 10)
Explorer.CurrentFolder = Folder;
else
Explorer.GetType().InvokeMember("SelectFolder", BindingFlags.InvokeMethod, null, Explorer, new object[] { Folder });
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
Posted 22 Apr, 2015 22:44:46 Top