Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

screen resolution problem..

Status
Not open for further replies.

tommy19

Programmer
Aug 23, 2001
49
US
Howdy all,

I am just wondering. I have an application with a print preview function which only allows for a maximized screen. I created the app with 1024 x 768 resolution, however, I need it to resize for 600 x 800 automatically, otherwise a good portion of the form does not appear. Do I need to manually resize the form (in the code) for each control or is there an easier/better solution?

Thank you in advance!!

Tommy
 

Ok, If in properties you set the windowstate = vbmaximized then you should not have to resize the form for a lower resolution, but you will have to reposition/resize your controls in the forms resize event. If however you set the size and width in code then you should set the width = screen.width and the height = screen.height and do the resize code mentioned above.

Good Luck

 
Thank you! How do I know which resolution the screen is set at?
 
I would like to ask a question about this post.
vb5prgrmr,
you said you would have to reposition your controls in the forms resize event. how would you know where to reposition them to?

I have not ran into a resolution peoblem yet but I think it would be good for me to know.

Thanks
 
I designed the form in both resolutions and recorded the positions, a little time consuming but not too bad. I can't think of any other way.
 

tommy19,

To know what the resolution is set at you can do ...
[tt]
Private Sub Form_Resize()

Dim W As Long, H As Long
W = Screen.Width / Screen.TwipsPerPixelX
H = Screen.Height / Screen.TwipsPerPixelY

End Sub
[/tt]

dvannoy,

It is best to start a new thread but since it is closly related to tommy19 here goes.

You can usually do some simple calculations to get your controls to look the same. Meaning in your sized view if you have a textbox whose left and top are 30 but its width is 3000 on a 1600 x 1200 resolution then what is that percentage? 3000/24000 (assuming form is maximized) then your percentage = 0.125 or ...
[tt]
Option Explicit

Private Sub Form_Resize()

Dim W As Long, H As Long
W = Screen.Width / Screen.TwipsPerPixelX
H = Screen.Height / Screen.TwipsPerPixelY

Text1.Width = Me.Width * 0.125

End Sub
[/tt]

Now when you resize the form from normal to max or with different resolutions your form should keep its aspect ratio. EXCEPT, you will have to change font sizes of your controls to keep everything looking the same. So if you design in a 640 x 480 environment then you will have to increase your font size (and lets not forget about height (and yes you can use percentages their also)). The VB default for font size is 8.25 (8) so increasing it to 10 or if needed to decrease it to 6 should not pose any problems depending upon the resolution(s). The best thing that I can say is to experiement with changing your resolution and invoking the resize code of the form(s) to see the results that you achieve. Once you have what you think is a good set of values then its time to goto work/friends etc. and run it on their different sized monitor. Depending upon who your target audience is you may only want to test it on 17, 19 and 21 but it would be best if you test it on all sizes of monitors (14, 15, 17, 19, 21, and if you export to tv you could give that a go also) with all resolutions. I believe that you will find the break points of where you should change your font sizes etc. it will just take a little experimentation.

On the other hand there are some 3rd party controls that will do a lot of this for you.

Good Luck to both of you

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top