Screen Resolution Handling - VB Screens developed as Active X Controls !

ajerath used Ask the Experts™
Hi Friends,

We developed an Intranet/Internet Application using VB 6.0, in which all the Screens have been developed as Active X Controls, these Active X Controls get downloaded on the user's machine for the first time whenever user accesses a particular screen.

Now, we have run into Screen Resolution Issues as different users use Screen Resolutions ranging from
640 X 480 to 1600 X 1200. We used 1024 X 768 Resolution while designing all the screens...and that was a mistake...!

I did try using Sizer Controls from Component One, as well as similar stuff from other vendors too - but none of them work in a proper fashion to resize (height, width, top, left, font, etc) all the controls present in a screen.

Our Screen layouts are in following manner:-

1. User Control       (Primary Container)
1.1 SSTab Control     (Secondary Container)
1.1.1 Frame           (Tertiary Container) Text Boxes, Labels, Drop Downs, Grids, etc

I am looking forward to some universal solution so that once implemented our application works in almost all the supported Screen Resoltuions.

If you have handled any such scenario in ur projects, do let me know. Even smaller guidelines will be quite helpful.

thanx for your time,

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Perhaps you could try this:

When your control loads, setup a VF and HF (vertical & horrizontal) factor according to the screen size e.g.

HF = Screen.Width / 1024
VF = Screen.Height / 678

Now you can multiply all of the coordinates on your control by these factors and the problem should be resolved. Also Adjust the font sizes by the average, or smaller of the factors.  You may also need to set style to flat, this is becuase you are permitted smaller fonts in flat mode.

Example (in practice you don't need to :


For each Ctrl in UserControl.Controls
If TypeOf Ctrl is VB.textBox
 ctrl.Left = ctrl.Left * HF
 ctrl.width = ctrl.width * HF = * VF
 ctrl.Height = ctrl.Height * VF
 ctrl.font.size=  ctrl.font.size * SmallF

Frame1.Height = Frame1.Height * WH

ElseIf TypeOf Ctrl is VB.textBox then

Your problem will be that there is a bug in the SSTab control, if you change the .Left of a control the display gets screwed. But if this is done before the control is displayed first time the bug may not manifest itself.  If it does call Microsoft for a solution....

The VB help section "UserControl object, accessing ContainedControls collection" gives info on how to loop through all controls.
Hope this helps:~)
You should be able to implement this with a general sub to work with all controls.

VF = Screen.Height / 768 ' this was wrong

But you said that when you used a 3rd party control it didin't work.  I suspect that this was becuase you must make all controls flat .Appearance set to flat. It is impossible to say why you need to do this without being a bit rude about Microsoft, so I won't.
I can't seam to get this to work.  Here is what I have...
None of the contorls are re-sizing..

Public Sub Form_Load()
HF = Screen.Width / 1024
VF = Screen.Height / 768
End Sub

Public Sub Form_Resize()

SmallF = IIf(HF < VF, HF, VF)

For Each ctrl In Form1.Controls
If TypeOf ctrl Is VB.TextBox Then
    ctrl.Left = ctrl.Left * HF
    ctrl.Width = ctrl.Width * HF
    ctrl.Top = ctrl.Top * VF
    ctrl.Height = ctrl.Height * VF
    ctrl.Font.Size = ctrl.Font.Size * SmallF
ElseIf TypeOf ctrl Is VB.TextBox Then
End If
Next ctrl
End Sub
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!


Hi inthedark,

We did try the formulae you mentioned for resizing and realigning of all the controls in the UserControl, but this is not a perfect or universal solution because it works a bit fine for the screens having lesser controls, but the screens having lots of constituent controls - the layout and design of the screen goes haywire.

We also tried some customized-solutions for each screen using the same formulae but none of them works perfectly.

thanx for the guidance,
In theory if VB had no bugs and did what it was told there is no reason why this should not work.

You should make the adjustment in the form load or UserControl_initialize, the resize is/can be be fired more than once. Also you have to adjust all controls, not just text boxes.  So its worth a try before redesigning all screens.  But I still think that changing the .Left property of a texbox on a SSTab will cause problems becuase of bug in VB.

Sub Form_Load() or UserControl_Initialise

dim HF as Single
dim HF as Single
dim SmallestF as Single

HF = Screen.Width / 1024
VF = Screen.Height / 768

SmallestF = IIf(HF < VF, HF, VF)

For Each ctrl In Me.Controls ' or userControl

on error resume next  
   ctrl.Left = ctrl.Left * HF
   if err.number <> 0 then exit do

   ctrl.Width = ctrl.Width * HF
   ctrl.Top = ctrl.Top * VF
   ctrl.Height = ctrl.Height * VF
   ctrl.Font.Size = ctrl.Font.Size * SmallestF
   Exit Do


End Sub
Actually I thing a change is required.
  err.clear ' add this line here
  ctrl.Left = ctrl.Left * HF ' this is the line that will screw a SSTAB.
PS The traditional way of handling different resolutions is to place all controls onto a picture box. If the screen resolution will not allow all controls to be visible to add scroll bars to the bottom/right side of the form/control.  Eventually users who get fed up with scrolling buy a bigger screen.
inthedark, quick question, Just somthing i have been wondering, how can you make a scroll bar move a form with out the form being a MDI from parent?

Lets take the default form that loads when you open visual basic, lets say i want to ad 10 text boxes in it, but i want the form to be small, is this possible?
Simple, place all control in a picture box. In your form resize you detect if current form width/height needs scroll bars. If you need a scroll bar you need to re-check that you don't need the other scoll bar.  Then you make the picture top negative to scroll up and picture left negative to scroll right. You set the scroll bar max to the different between actual size required and me.scalewidth.

It sounds hard but the are several easy examples on the net.
Author of the Year 2009

Hi ajerath,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept inthedark's comment(s) as an answer.

ajerath, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept THIS comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
DanRollins -- EE database cleanup volunteer

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial