Solved

Screen Resolution  - Dumb Question

Posted on 1998-11-05
4
155 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
[X]
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
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

752 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