Solved

VB6 Resize buttons, forms etc

Posted on 2010-09-17
3
433 Views
Last Modified: 2013-12-25
Basically I have a VB6 program that when run maximizes form1 to fit the screen, the problem I have is that this program was written for a resolution of 1024x768 so when it is run on a lower resoloution not everything fits in (buttons etc) and on a higher resolution has big gaps round the edges.

I still want the program to be maximised when opened but I want all the buttons, textboxes etc to be resized so on a lower resolution become smaller and on a higher become bigger so they fill the screen exactly the same as with the current 1024x768 resolution.
0
Comment
Question by:souldigital
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 18

Expert Comment

by:Cluskitt
ID: 33701456
What you want is a percentage. Set the form to 1024x768. We're assuming here you have a button and a textbox.Button has 10 width, 3 height. Textbox has 20 width, 3 height.
Now, what you want is to set the ratio when the form opens.

scrHeight=Screen.Height
scrWidth=Screen.Width
Button.Height=3*scrHeight/1024
Button.Width=10*scrWidth/768
Textbox.Height=3*scrHeight/1024
Textbox.Width=20*scrWidth/768

Something like this, anyway. You might have to also use something similar to calculate Left and Top properties.
0
 
LVL 14

Accepted Solution

by:
VBClassicGuy earned 500 total points
ID: 33701475
0
 
LVL 5

Expert Comment

by:BrianVSoft
ID: 33707273
We use code similar to the code sample linked by VBClassicGuy
We had to add several extra bits in the FormResize event.
1. If Me.WindowState = 1 Then Exit Sub  '(This prevents an error when Minimizing.)
2. If you have lots of controls, that example will be too slow because it will try to resize everything a hundred times a second (with every pixel of mouse movement) We had to include an Exit Sub if the NEW Width+Height was within a few percent of OLD Width+Height. (a simple line of math) This restricted resizing to only occur once every tenth inch or so.
3. The example also attempts to center the form on the screen - most users won't want that- those few lines can be removed.
4. You should also Exit Sub if the Width or Height is now less than a preset minimum size.
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question