Outlook Custom form - resize event handling

V

VB3T

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!
 
K

Ken Slovak - [MVP - Outlook]

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.
 
V

VB3T

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 - said:
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.
 
K

Ken Slovak - [MVP - Outlook]

An Inspector is the window used to display Outlook items. When that event
fires the window is about to be resized. An Inspector has Top, Left, Height
and Width properties. If the form is being resized it's the front window so
you can get its hWnd usually from GetForegroundWindow.
 
V

VB3T

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 - said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top