Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VB6 Resize buttons, forms etc

Posted on 2010-09-17
3
Medium Priority
?
438 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 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

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