Thursday, 4 December 2008

OI - Did you know?

For a while, I have been frustrated by the sizing of windows in my apps especially when thinking about users making them smaller than they are designed. An action that often results in controls that are not visible. I know that sometimes a form that is designed for 1024x768 will be partially off screen when viewed on a screen running 640 x 800 for instance. You can’t legislate for everyone, but it’s nice to catch most.

Anyway, I stumbled on a nice little work around to this issue, the product of accidentally setting the auto resize properties of a label, instead of an edit table – well it was late ;-). It is also useful if you can't control the resizing of your windows, (for instance MDI children) but you do not want the form to sized smaller than the controls on the form and mess up your well designed and balanced forms.

This neat trick is achieved by dropping a label onto the form, removing the text and setting the background colour – or simply making it invisible. You then check (tick) the autosize height and width properties for the control.

The form will allow the user to make the window smaller, but only by the size of the label. Once the label reaches 0:0, it will not resize any smaller and stops the whole window from being made smaller. I have my windows open up at the size I designed them to be (usually the optimal size) and then have a 1:1 sized label so that it gives the user the impression that the window can only be sized bigger and not smaller.

This simple method, still leaves the user with the ability to make the window as large as they want, but you can usually handle those aesthetics through making other controls auto resizable and setting their anchor properties.

2 comments:

  1. Martyn - You must have missed my presentation in Vegas. We have a free utility for this, that allows you set both the minimum and maximum size of the window - to prevent specifically what you are talking about. Shoot me an email and I'll send you the link to the whole suite if you want them. Frank - SRP.

    ReplyDelete
  2. FYI:

    OI 9.0 WINDOW objects have a new property called TRACKINGSIZE:

    This is an @fm delimited array that specifies the minimum and maximum
    sizes that a window can be dragged to with the mouse/keyboard.

    <1> Minimum tracking width
    <2> Minimum tracking height
    <3> Maximum tracking width
    <4> Maximum tracking height

    If the maximum and minimum values are set the same then the window
    cannot be resized. This is this means that you can created fixed size
    MDI children.

    ReplyDelete