Unexpected behaviour when handling resize event in ADXOlForm for Inspector

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

Unexpected behaviour when handling resize event in ADXOlForm for Inspector
 
nwein




Posts: 577
Joined: 2011-03-28
Consider the following:
1. Create a brand new Com Addin for Outlook (2010, 32-bit)
2. Add an ADXOlForm (called ADXOlForm1)
3. Subscribe to the form's resize event, e.g. this.Resize += new System.EventHandler(this.ADXOlForm1_Resize);
4. Add the following code in the ADXOlForm1_Resize handler:

private void ADXOlForm1_Resize(object sender, EventArgs e)
{
	if (Width < 200)
		Width = 200;
}

5. In the AddinModule add an ADXOlFormsManager (called adxOlFormsManager1)
6. Add an ADXOlFormsCollectionItem to adxOlFormsManager1(called adxOlFormsCollectionItem1)
7. Set the adxOlFormsCollectionItem1 InspectorItemTypes to Mail
8. Set the adxOlFormsCollectionItem1 InspectorLayout to RightSubpane (make sure the the InspectorMode is set to Read;Compose (default))
9. Set the adxOlFormsCollectionItem1 FormClassName to MyAddin1.ADXOlForm1 (the form created in step 2)
10. Register and debug your add-in
11. Open an email to compose or read (i.e. using the Inspector)
12. Attempt to resize the task pane to be less than 200

--> The task pane completely disappears.

I can only presume this is a bug and not the intended behaviour, right?
I can send you a sample project though these are the exact same steps I've done.
Posted 17 Feb, 2015 14:44:05 Top
Andrei Smolin


Add-in Express team


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

Resizing a form in the Resize event isn't something that the ADXOlForm (as well as the underlying System.Windows.Forms.Form) is prepared to.

To prevent the user from resizing the form, you can set ADXOlFromscollectionItem.Splitter = None; this allows setting the form size progammatically.

To maintain the required form size, you can use the ADXSplitterMove event available on the form.

Alternatively, you can use this approach:

void ADXOlForm1_ADXPostMessageReceived(object sender, ADXPostMessageReceivedEventArgs e)
    {
        if (e.WParam == (IntPtr)1)
            Width = 200; 
    }
    private void ADXOlForm1_Resize(object sender, EventArgs e)
    {
        if (Width < 200)
            ADXPostMessage((IntPtr)1, IntPtr.Zero);
    }



Andrei Smolin
Add-in Express Team Leader
Posted 18 Feb, 2015 06:59:10 Top
nwein




Posts: 577
Joined: 2011-03-28
Interesting. I thought that resizing within a resize event is just like a recursive call, but not something that is not handled properly...
I don't want to restrict the user from resizing, just to set the limits as to how much the pane can be resized.
Having said that, the ADXSplitterMove event works flawlessly (and is actually more elegant).
Thanks for the suggestions!
Posted 18 Feb, 2015 11:17:27 Top
Andrei Smolin


Add-in Express team


Posts: 18829
Joined: 2006-05-11
You are welcome!


Andrei Smolin
Add-in Express Team Leader
Posted 19 Feb, 2015 03:48:51 Top