How can I determine # of monitors and the resolution of each?

Posted on 2013-08-30
Medium Priority
Last Modified: 2013-08-31
When exiting my program, I write the form's position (X, Y) (i.e. LEFT, TOP) to the registry, and read it when my form starts up next. A problem recently occurred in that if I change screen resolution between, opening the small form at its last position may be entirely "off screen" and hence opens it minimized (form does maximize - so it can't be placed in a viewable position).

So I need to make an adjustment or two (recommendations appreciated), but I need to know  if the (X, Y) stored falls inside the monitor(s') resolution(s).

TIA - Ed
Question by:Ed Covney
LVL 24

Accepted Solution

jimyX earned 2000 total points
ID: 39454573
To get the number of monitors:

Use "Screen.MonitorCount"    e.g. showmessage(inttostr(Screen.MonitorCount));

And to get the resolution of each monitor, use Width and height:
Screen.Monitors[0].Width  // 0 is the first monitor

My suggestion is to make a proportional adjustment to your form based on the resolution (if using the Anchor property is not sufficient).
For instance, if the Width x Height is 800x600 but your application default size is set to view 1366x768 then make proportional adjustment by altering the form and/or controls accordingly.

You may read this useful link.

Author Closing Comment

by:Ed Covney
ID: 39455035
jimyX -

Thank you - This is exactly what I was hoping for !!

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Understanding the various editions available is vital when you decide to purchase Windows Server 2012. You need to have a basic understanding of the features and limitations in each edition in order to make a well-informed decision that best suits …
This article provides a step by step guide (with screenshots) showing how to create a new local (test) Administrator user profile in Windows 10 for troubleshooting purposes, and then how to remove it.
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

587 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