Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Screen Resolution  - Dumb Question

Posted on 1998-11-05
4
Medium Priority
?
158 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 400 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

916 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