Question : Is there a quick way to resize forms and controls?!

We have an big software made in WinForm VB 2008 designed with 1280X1024 forms. Previous version of our software worked on 1024X768 screens. Now, we are upgrading those clients with the newer version, but the touch-screen (it's an embedded industrial computer) does not support 1280X1024 resolution (it's something we all missed before giving the go-ahead for the upgrade). So, we have to resize all the forms and controls, and spacing between each controls, to fit the 1280 interface into 1024.

We decided to make a new version and copy/paste all control and code and manually resize the whole things (there are a lot of forms and controls...) which will take very much time. Ideally, we should have a single version that support both resolutions, as maintenance of both versions will quickly become a nightmare.

Anyone have an idea of how we could automatically resize forms and controls, depending of the resolution? Getting the best resolution of the graphic card is not a problem, it's the resizing of forms and controls that give us headache...

thanks for your time and help

Answer : Is there a quick way to resize forms and controls?!

I've always made my controls re-sizable to any resolution simply by implementing the form_resize event. Instead of using fixed positions, calculate them in this event. Don't assign Top, Width, Height, etc constant values - use a series of formula to calculate how much space is available, and what their respective positions should be relative to each other.

It will take a little effort this first time, since you're overhauling the UI layout, but after that you'll never have to worry about resolution problems again.

I've attached an example.

--
Alain
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
Const ListboxPadding = 1
Const ButtonPadding = 3
Const MinHeight = 100
Const MinWidth = 520

Private Sub UserForm_Resize()
    With ButtonSearchBasic
        .Top = Me.InsideHeight - ButtonPadding * 2 - .Height
    End With
    With ButtonSearch1
        .Top = Me.InsideHeight - ButtonPadding * 2 - .Height
    End With
    With ButtonSearch2
        .Top = Me.InsideHeight - ButtonPadding * 2 - .Height
    End With
    With ButtonExit
        .Top = Me.InsideHeight - ButtonPadding - .Height
        .Left = Me.InsideWidth - ButtonPadding - .Width
    End With
    With ButtonFillOverwrite
        .Top = Me.InsideHeight - ButtonPadding - .Height
        .Left = Me.InsideWidth - ButtonPadding * 4 - .Width - ButtonExit.Width
    End With
    With ButtonFillEmpty
        .Top = Me.InsideHeight - ButtonPadding - .Height
        .Left = Me.InsideWidth - ButtonPadding * 6 - .Width - ButtonFillOverwrite.Width - ButtonExit.Width
    End With
    With ResizeGrab
        .Left = Me.InsideWidth - .Width
        .Top = Me.InsideHeight - .Height
    End With
    With ResultList
        .Top = ListboxPadding
        .Left = ListboxPadding
        .Height = Me.InsideHeight - 2 * ButtonPadding - ButtonExit.Height - .Top
        .Width = Me.InsideWidth - .Left - ListboxPadding
    End With
End Sub
Random Solutions  
 
programming4us programming4us