Resizable User Forms

In Office XP, Microsoft made the File O Open and File O Save As dialogs resizable. They remember their position and size between sessions, greatly improving their usability. Using the same API calls shown in the previous section and a class module to do all the hard work, you can give your users the same experience when interacting with your UserForms.

One of the curiosities of the UserFormobject is that it has a Resize event, but it doesn't have a property to specify whether or not it is resizable — the Resize event only fires when the form is first displayed. As shown in the previous example, you can provide your own Sizeable property by toggling the

WS_THICKFRAME window style bit; when you do this, the Userform_Resize event comes to life, triggered every time the users change the size of the form (though not when they move it around the screen). You can respond to this event by changing the size or position of all the controls on the form, such that they make the best use of the UserForm's new size.

There are two approaches that can be used to change the size or position of all the controls on the form: absolute and relative.

0 0

Post a comment