Size Form dependant on screen resolution

I have this to get the screens resolution :

Dim scrX As Integer
Dim scrY As Integer

srcX = Screen.Width / Screen.TwipsPerPixelX
srcY = Screen.Height / Screen.TwipsPerPixelY

I would like to be able to set the forms height and width dynamically dependant on the end users screen resolution and so that the form fills the middle of the screen so that there are a few inches either side of the form between the edge of each side of the form and the edge of the monitor and at the same time to resize the controls on the form as relevant.

Any help would be very much appreicated!!!
LVL 23
Shane Russell2nd Line Desktop SupportAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rettiseertCommented:
This will center the form at 80% of screen resolution (80% = .8)

    Dim scrX As Long
    Dim scrY As Long

    scrX = Screen.Width / Screen.TwipsPerPixelX
    scrY = Screen.Height / Screen.TwipsPerPixelY
   
    Me.Width = Me.ScaleX(scrX, vbPixels, vbTwips) * 0.8
    Me.Height = Me.ScaleY(scrY, vbPixels, vbTwips) * 0.8
   
    Me.Move (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 2
rettiseertCommented:
And for resizing controls... that depends on how do you want they look. One easy way is to use a component like

http://www.vbgold.com/index.shtml#ActiveResizeControlLite

its free, and will do the job for you.
Shane Russell2nd Line Desktop SupportAuthor Commented:
How do I use that active resize control ? Do I go to project --> References and add the ocx control and then use it or do I have to add it as a component or what ?
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

rettiseertCommented:
Download the setup program for the lite (free) version on the control and run it.
In VB add it as a component.
Insert the control in your form.
PaulHewsCommented:
Best practice normally dictates that you create your form with the lowest supported resolution in mind.  800x600 should be low enough.   Generally those resizing controls can produce goofy looking applications at extreme resolutions (high and low.)  What I generally do, if my dialog has a fixed border, I make sure it's small enough to fit a low resolution screen.  I tend to use this for simple quick entry dialogs.  If something requires resizing, I will move controls around the form take advantage of  the form's rescaling, but I won't resize the controls.

So having said that, why do you want your form to be scaling to this particular size?
PaulHewsCommented:
Besides the goofy looking forms, also remember that if someone has a high resolution set up, it's because they want the screen real estate... They don't *want* your form covering 90% of their 25 inch display.
Shane Russell2nd Line Desktop SupportAuthor Commented:
Becuase I have 2 frames and within those frames I will be adding a file explorers similiar to nero burning rom and It would look funny if the frames were left in tact and the form changed especially since being able to read the names of the files if I or another user were trying to find specific music files to transfer to the mp3 player(s).

So I need it to be re sized to allowe for the screen resolution so that the items within the file explorers are legible.

It is mainly an application for myself that I am making because I normally swap between screen resolutions and I dont want to going back and forth between my mp3 player drive and finding the music I just want to be able to do it from one place just like Rio Music manager does.
Shane Russell2nd Line Desktop SupportAuthor Commented:
FYI - The mp3 player I have is not a Rio Mp3 player so I dont get any software with it, the only thing I got with this mp3 player was some drivers and thats it !!
PaulHewsCommented:
What controls are you using as file explorers?
vinnyd79Commented:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Shane Russell2nd Line Desktop SupportAuthor Commented:
Thanks for the help everyone !

I am using frames and I am still looking for some controls that are simmiliar to Nero where it displays the file explorer type interface on one side and then the directory ie files and folders on the other side, if that makes sense ?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.