Solved

Screen Resolution  - Dumb Question

Posted on 1998-11-05
4
149 Views
Last Modified: 2010-04-30
OK, I have made several pretty cool applications.

However, if someone uses a different Screen Resolution
then my application looks too big or too small.

In other words, I'm using and programming for 800x600.
If a user has 640x400 then he only see's 3/4 of my
application screen. If the User has 1200x1000 screen res
or whatever, then my application appears very small and
only partially fills the screen, leaving lots of dead space.

I always thought Windows was supposed to take care of that.
Why doesn't it? How do I make it do that?
We don't have to program for each screen resolution do we?
That would just be stupid!
0
Comment
Question by:jgore
4 Comments
 
LVL 15

Expert Comment

by:ameba
ID: 1443449
If you are programming for Windows, do it proper. In Windows, generaly, there is no place for resizing and repositioning controls. Every program must fit to 640*480 resolution.

When user changes resolution to e.g. 1280*960, he/she wants to see more information, not your enlarged information.

There are some resize.ocx-es on the market. They are catching
non-windows programmers, used to do their applications full-screen.

If you have data-entry screen with a lot of fields, do not enlarge your forms, use Tabstrip control instead. This will keep your forms small enough to fit 640x480.

This is a general rule. Exceptions are: setup programs, screen savers and some games. Full-screen can be OK for these applications.
0
 

Expert Comment

by:FatAlbert
ID: 1443450
get the screen.width and screen.height values and use them to scale your application. it works perfectly.
0
 

Author Comment

by:jgore
ID: 1443451
FatAlbert:
How do I do that?
I know how to get the screen.width and screen.height, but what then?
How do I use them to scale my application?
Your answer is more than a little vague. I need details, or code, or something!
Thanks for any reply................

P.S. It's really very confusing:
We have Screen.height, Screen.width, form1.height, form1.width,
form1.scaleheight, form1.scalewidth and probably some other crap!
What do I do with it all?
0
 
LVL 1

Accepted Solution

by:
mithomas earned 100 total points
ID: 1443452
Totally disregard what the resolution of the graphics card is set to.  You need to write code in the resize event of your main form (or, really, any resizeable window) to size relevant controls to useful sizes relative to the size of the main form.

For example, let's say that your main form has a ListView in the top half and the bottom half is dominated by a bunch of TextBoxes(single-line).  When your user resizes this window, what do you think should happen?  I think the ListView in the top should grow/shrink as a the size of the form changes.  Why?  Because it makes sense to grow and shrink The listview (it can show more data as it grows, but less so the TextBox-dominated part of the window.  It may make sense to make the TextBoxes wider or narrower depending upon the size of the window, but it's a less certain thing.

Now, how to write this code?

Key everything off of Form.Width and Form.Height.  Your code will look something like:

----------------------------------

'Resize important controls relative to size of window
Sub Form1_Resize()
  Const TB_AREA_HEIGHT = 200 'Size of "TextBox Area" Height
  Const BREATHING_ROOM = 100 'Room between controls
                             'and edge of form

  'Only resize controls if not minimized (safest way)
  If Me.WindowState <> vbMinimized Then
    'Size ListView to take up majority of window
    ListView1.Height = Me.Height - TB_AREA_HEIGHT
    ListView1.Width = Me.Width - BREATHING_ROOM

    'Size Width of one TextBox, because it sometimes holds
    'long data
    TextBox4.Width = Me.Width - BREATHING_ROOM
  End If

End Sub

----------------------------------

I just made this code up off the top of my head, so don't paste it into a form and expect it to work perfectly.  It's just an example of the kind of thing you'd do.  I'm currently working on an app that has a horizontal splitter that I wrote in VB, and it has tons of resizing code due to splitter position changes, form resizing, etc.  It's just what you do.

Good luck...

----------------------
Mike Thomas
Digital Answers, LLC
www.digitalanswers.com
----------------------
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…

705 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now