Screen Resolution  - Dumb Question

Posted on 1998-11-05
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!
Question by:jgore
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
LVL 15

Expert Comment

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.

Expert Comment

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

Author Comment

ID: 1443451
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?

Accepted Solution

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

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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
Course of the Month9 days, 17 hours left to enroll

624 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