You are here: Office-Outlook.com  / Outlook Forum

Outlook Custom form - resize event handling

Home » Outlook addins and plugins development » Developer Outlook add-ins
Outlook Custom form - resize event handling [message #574] Thu, 06 July 2006 13:41 Go to next message
VB3T
Messages: 4
Registered: June 2006
Junior Member
Hi all,

I used standard Message template and added custom control (RTF editor) on
the form. I want to make that control resizes when user resizes the new
message window (similar to standard Message textbox).
I hid the standard message textbox and added code in Item_Open() to make my
control overlap original - so initial size and position are correct (see code
below). And I checked the box 'resize with form' for the new control.
However, only control's width got resized with form but its height remained
the same.

Sub Item_Open()
Dim oPage
Dim oTIS, oOld
Set oPage = Item.GetInspector.ModifiedFormPages(1)
Set oTIS = oPage.Controls(oPage.Controls.Count - 1) ' custom control is
the last one
Set oOld = oPage.Controls("Message") ' original textarea
oTIS.Move oOld.Left, oOld.Top, oOld.Width, oOld.Height
Set oTIS = Nothing
Set oPage = Nothing
End Sub
To test that piece of code you can create a form and put new multiline
textbox...

As workaround I tried to add a hook on parent window and resize my control
whenever parent gets resized... More problems here:
- immediate parent gets lost when form resizing causes vertical scrollbar
disappear or appear;
- when I tried to use next parent then attempts to move
the control based on parent size (GetWindowRect) resulted in weird positions
(and also depended on fact either scrollbar was visible or not);
- I used Spy++ trying to identify windows hierarchy and found discrepancy
between standard mail message form and customized (i.e. some 'F3 Server
600..." window etc.). It seems form customization added some additional
layers...

I believe there should be some way to overcome those issues (maybe my
control should expose some interface so it's container will resize it
properly?)

Any help is highly appreciated!
--
Thanks,
VB
Re: Outlook Custom form - resize event handling [message #576] Thu, 06 July 2006 15:31 Go to previous messageGo to next message
VB3T
Messages: 4
Registered: June 2006
Junior Member
Thanks for prompt response!
I'm using add-in already. Yes, I can subscribe on Inspector.BeforeSize event
but it's pretty much useless for me.
Is Inspector represents the message window itself? Then I'll try to add a
hook on the form and will resize... but this mean I need to calculate
position based on Subject textbox etc... :(
--
Thanks,
VB


"Ken Slovak - [MVP - Outlook]" wrote:

> Those are some of the limitations of custom forms. If you think getting the
> hWnd for a custom form is bad try getting it and process/thread/window
> ownership for a WordMail Inspector window.
>
> Most ActiveX controls placed on a form only will fire their Click events,
> despite whatever other events they might expose. There's an
> Inspector.BeforeSize event, but you can't subscribe to that in form code.
>
> What I usually do is to first of all avoid custom forms unless absolutely
> necessary due to their limitations and frailty. If they are unavoidable I
> pair them with a COM addin. If I can I just use an addin and a custom form
> from there, possibly called up from an Inspector button created and
> monitored by the addin.
>
> Back to your problem. I would use an addin to monitor Inspector.Resize for
> all open items in which you are interested. When that event fires I'd read
> the new size and access the form control and resize it, dimensions based on
> the new Inspector size.
>
> See http://www.outlookcode.com/d/forms.htm for lots of form design
> information.
>
> --
> Ken Slovak
> [MVP - Outlook]
> http://www.slovaktech.com
> Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
> Reminder Manager, Extended Reminders, Attachment Options
> http://www.slovaktech.com/products.htm
>
>
> "VB3T" <VB3T@discussions.microsoft.com> wrote in message
> news:96F568E2-1A0B-4770-B613-A7457F681B2E@microsoft.com...
> > Hi all,
> >
> > I used standard Message template and added custom control (RTF editor) on
> > the form. I want to make that control resizes when user resizes the new
> > message window (similar to standard Message textbox).
> > I hid the standard message textbox and added code in Item_Open() to make
> > my
> > control overlap original - so initial size and position are correct (see
> > code
> > below). And I checked the box 'resize with form' for the new control.
> > However, only control's width got resized with form but its height
> > remained
> > the same.
> >
> > Sub Item_Open()
> > Dim oPage
> > Dim oTIS, oOld
> > Set oPage = Item.GetInspector.ModifiedFormPages(1)
> > Set oTIS = oPage.Controls(oPage.Controls.Count - 1) ' custom control is
> > the last one
> > Set oOld = oPage.Controls("Message") ' original textarea
> > oTIS.Move oOld.Left, oOld.Top, oOld.Width, oOld.Height
> > Set oTIS = Nothing
> > Set oPage = Nothing
> > End Sub
> > To test that piece of code you can create a form and put new multiline
> > textbox...
> >
> > As workaround I tried to add a hook on parent window and resize my control
> > whenever parent gets resized... More problems here:
> > - immediate parent gets lost when form resizing causes vertical scrollbar
> > disappear or appear;
> > - when I tried to use next parent then attempts to move
> > the control based on parent size (GetWindowRect) resulted in weird
> > positions
> > (and also depended on fact either scrollbar was visible or not);
> > - I used Spy++ trying to identify windows hierarchy and found discrepancy
> > between standard mail message form and customized (i.e. some 'F3 Server
> > 600..." window etc.). It seems form customization added some additional
> > layers...
> >
> > I believe there should be some way to overcome those issues (maybe my
> > control should expose some interface so it's container will resize it
> > properly?)
> >
> > Any help is highly appreciated!
> > --
> > Thanks,
> > VB
>
>
Re: Outlook Custom form - resize event handling [message #587] Fri, 07 July 2006 15:06 Go to previous message
VB3T
Messages: 4
Registered: June 2006
Junior Member
Hi again,

I finally made it work ... I used hWnd of my control and called recursively
GetParent until I get hWnd of the message window (Inspector?), and used that
to get its size and resize my control (only height). It's a bit ugly but it
works...

I'll be back with more questions... right now I am actively reading
outlookcode.com and slovaktech.com (thanks!!) for more details about adding
toolbar and buttons to Inspector.

I may be back with more questions :)
--
Thanks,
VB


"Ken Slovak - [MVP - Outlook]" wrote:

> Those are some of the limitations of custom forms. If you think getting the
> hWnd for a custom form is bad try getting it and process/thread/window
> ownership for a WordMail Inspector window.
>
> Most ActiveX controls placed on a form only will fire their Click events,
> despite whatever other events they might expose. There's an
> Inspector.BeforeSize event, but you can't subscribe to that in form code.
>
> What I usually do is to first of all avoid custom forms unless absolutely
> necessary due to their limitations and frailty. If they are unavoidable I
> pair them with a COM addin. If I can I just use an addin and a custom form
> from there, possibly called up from an Inspector button created and
> monitored by the addin.
>
> Back to your problem. I would use an addin to monitor Inspector.Resize for
> all open items in which you are interested. When that event fires I'd read
> the new size and access the form control and resize it, dimensions based on
> the new Inspector size.
>
> See http://www.outlookcode.com/d/forms.htm for lots of form design
> information.
>
> --
> Ken Slovak
> [MVP - Outlook]
> http://www.slovaktech.com
> Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
> Reminder Manager, Extended Reminders, Attachment Options
> http://www.slovaktech.com/products.htm
>
>
> "VB3T" <VB3T@discussions.microsoft.com> wrote in message
> news:96F568E2-1A0B-4770-B613-A7457F681B2E@microsoft.com...
> > Hi all,
> >
> > I used standard Message template and added custom control (RTF editor) on
> > the form. I want to make that control resizes when user resizes the new
> > message window (similar to standard Message textbox).
> > I hid the standard message textbox and added code in Item_Open() to make
> > my
> > control overlap original - so initial size and position are correct (see
> > code
> > below). And I checked the box 'resize with form' for the new control.
> > However, only control's width got resized with form but its height
> > remained
> > the same.
> >
> > Sub Item_Open()
> > Dim oPage
> > Dim oTIS, oOld
> > Set oPage = Item.GetInspector.ModifiedFormPages(1)
> > Set oTIS = oPage.Controls(oPage.Controls.Count - 1) ' custom control is
> > the last one
> > Set oOld = oPage.Controls("Message") ' original textarea
> > oTIS.Move oOld.Left, oOld.Top, oOld.Width, oOld.Height
> > Set oTIS = Nothing
> > Set oPage = Nothing
> > End Sub
> > To test that piece of code you can create a form and put new multiline
> > textbox...
> >
> > As workaround I tried to add a hook on parent window and resize my control
> > whenever parent gets resized... More problems here:
> > - immediate parent gets lost when form resizing causes vertical scrollbar
> > disappear or appear;
> > - when I tried to use next parent then attempts to move
> > the control based on parent size (GetWindowRect) resulted in weird
> > positions
> > (and also depended on fact either scrollbar was visible or not);
> > - I used Spy++ trying to identify windows hierarchy and found discrepancy
> > between standard mail message form and customized (i.e. some 'F3 Server
> > 600..." window etc.). It seems form customization added some additional
> > layers...
> >
> > I believe there should be some way to overcome those issues (maybe my
> > control should expose some interface so it's container will resize it
> > properly?)
> >
> > Any help is highly appreciated!
> > --
> > Thanks,
> > VB
>
>
Previous Topic:Debugging Word addin when Word is launched by another app
Next Topic:Re: Two CommandBarButtons that run the same event code
Goto Forum: