Problem showing custom form in Outlook Inspector window

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

Problem showing custom form in Outlook Inspector window
 
Goran Vidic




Posts: 61
Joined: 2009-04-24
Hi,

I'm having problem to see my ADXOlForm in inspector window after double clicking on task item. Inspector window is shown with original task window instead of my embeded window.

I'm using the followg code:


private void adxOutlookEvents_InspectorActivate(object sender, object inspector, string folderName)
{
   InspectorInitialization(inspector);
}

private void InspectorInitialization(object inspector)
{
    if ((inspector as Outlook.Inspector).CurrentItem is Outlook.TaskItem)
    {
        AddinExpress.OL.ADXOlForm selectedForm = null;
        try
        {            
            for (int i = 0; i < adxOlFormsCollectionItem1.FormInstanceCount; i++)   // Number of currently opened instances of FormClassName
            {
                selectedForm = adxOlFormsCollectionItem1.FormInstances(i);
                
                if (selectedForm != null)
                {
                    if (selectedForm is frmMyTaskRegion)
                    {
                        (selectedForm as frmMyTaskRegion).Show();
                        (selectedForm as frmMyTaskRegion).Activate();
                    }
                }                
            }
        }
        catch (Exception ex)
        {
            StaticVariables.logger.writeError(ex);
            Utility.ShowMessageBoxError(ex);
        }
        finally
        {
            if (selectedItem != null) Marshal.ReleaseComObject(selectedItem);
        }
    }
}




Am I missing something here?

Rergards, G. Vidic
Posted 02 Oct, 2009 03:27:21 Top
Andrei Smolin


Add-in Express team


Posts: 16986
Joined: 2006-05-11
Goran,

I've posted a link to the sample demonstrating how to show/hide an Outlook from at http://www.add-in-express.com/forum/read.php?FID=5&TID=6159.

Regards from Belarus (GMT+2),

Andrei Smolin
Add-in Express Team Leader
Posted 02 Oct, 2009 05:38:21 Top
Goran Vidic




Posts: 61
Joined: 2009-04-24
Hi Andrei,

My question is not on showing\hiding ADXOlForm, it's rather question on
"Activate()" method or how to bring our custom form on top ot the other forms when user double click on task item and shows Inspector window.

My code should "Activate" custom ADXOlForm when user double clicks on task item, and Inspector window for that item is shown. Instead of "activating" my custom form when Inspector window is opened, I must manually select it from drop-down list in order to bring them to the top.

Regards, Goran
Posted 05 Oct, 2009 03:06:29 Top
Andrei Smolin


Add-in Express team


Posts: 16986
Joined: 2006-05-11
Hi Goran,

I've just tested the following approach:

private const int WM_USER = 0x0400;
private const int WM_MyEvnt1 = WM_USER + 10;

private void adxOutlookEvents_InspectorActivate(object sender, object inspector, string folderName)
{
    this.SendMessage(WM_MyEvnt1, this.GetOutlookWindowHandle(inspector), IntPtr.Zero);
}

private void AddinModule_OnSendMessage(object sender, AddinExpress.MSO.ADXSendMessageEventArgs e)
{
    if (e.Message == WM_MyEvnt1)
    {
        AddinExpress.OL.ADXOlForm selectedForm;
        for (int i = 0; i < adxOlFormsCollectionItem1.FormInstanceCount; i++)   
        {
            selectedForm = adxOlFormsCollectionItem1.FormInstances(i);

            if (selectedForm != null)
            {
                if (selectedForm.CurrentOutlookWindowHandle == e.WParam)
                {
                    selectedForm.Activate();
                }
            }
        }
    }
}


Please let me know if it works for you.

Regards from Belarus (GMT+2),

Andrei Smolin
Add-in Express Team Leader
Posted 05 Oct, 2009 08:51:05 Top
Goran Vidic




Posts: 61
Joined: 2009-04-24
Hi Andrei,

Thank you for the code, but code for this.GetOutlookWindowHandle(inspector), is missing and I cannot try it.

Regards, Goran
Posted 06 Oct, 2009 03:25:46 Top
Andrei Smolin


Add-in Express team


Posts: 16986
Joined: 2006-05-11
Hi Goran,

Oh, that method was introduced in version 2009.

Regards from Belarus (GMT+2),

Andrei Smolin
Add-in Express Team Leader
Posted 06 Oct, 2009 03:54:22 Top
Goran Vidic




Posts: 61
Joined: 2009-04-24
Hi Andrei,

So, it is not possible to activate my custom form within Inspector window with "Add-in Express™ 2008 for .NET v4.4.1918" version of your product or I'm doing something wrong in my code?

Regards, G. Vidic
Posted 09 Oct, 2009 02:18:42 Top
Andrei Smolin


Add-in Express team


Posts: 16986
Joined: 2006-05-11
Hi Goran,

You can call QueryInterface to get the IOleWindow interface of the inspector window. Then you can call the GetWindow method of that interface.

Regards from Belarus (GMT+2),

Andrei Smolin
Add-in Express Team Leader
Posted 09 Oct, 2009 05:16:40 Top
Goran Vidic




Posts: 61
Joined: 2009-04-24
Hi Andrei,

Source code example would be highly welcomed, please!

Regards, G. Vidic
Posted 14 Oct, 2009 02:03:35 Top
Dmitry Kostochko


Add-in Express team


Posts: 2841
Joined: 2004-04-05
Hello Goran,

Please see the code below:

    IOLEWindow IWin = inspectorObj as IOLEWindow;
    IntPtr handle = IntPtr.Zero;
    IWin.GetWindow(out handle);


And declaration of the IOLEWindow interface:

[ComImport, ComVisible(false),
GuidAttribute("00000114-0000-0000-C000-000000000046"),
InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IOLEWindow
{
	void GetWindow(out IntPtr wnd);
	void ContextSensitiveHelp(bool fEnterMode);
}



Posted 14 Oct, 2009 05:52:54 Top