Board index » delphi » Change screen resolution

Change screen resolution

A possible solution to various screen resolutions would be a message box
that states "This program is best viewed at 800x600.  Do you want to
change your screen resolution to this?"  If yes, then set Screen.Width
and Screen.Height.  Unfortunately, those are read-only variables.

Is there a way to change screen resolution from within a Delphi 3
program?

BTW, a change in screen resolution would have to be reversed when the
program exits.  It would also affect all other running programs, so it
might not be a good solution for all cases.  My main concern is that
it's possible to scale a lot of controls, but I have a few grids and the
columns don't scale well.

Thanks for input and thoughts.

 

Re:Change screen resolution


Alan,

It's possible, but not easy....

You have to first make sure that the user's system supports the
resolution and color depth that your app requires using
EnumDisplaySettings().

Once you've established that their display does work with your
required settings, and they've OK'd making the change, you can
change the resolution/color depth with ChangeDisplaySettings().
You'll want to save their current resolution and color depth before
making the change.

At the end of your app, simply call ChangeDisplaySettings() again
with their old setting information.

You'll also need to find out if their video driver allows changing
resolutions / color depth without rebooting the system; you can
find out by testing the return value of ChangeDisplaySettings().
It will return DISP_CHANGE_SUCCESSFUL if the resolution change
worked, or DISP_CHANGE_RESTART if the change worked but the system
has to be restarted.

Quote
Alan MacArthur wrote:

> A possible solution to various screen resolutions would be a message box
> that states "This program is best viewed at 800x600.  Do you want to
> change your screen resolution to this?"  If yes, then set Screen.Width
> and Screen.Height.  Unfortunately, those are read-only variables.

> Is there a way to change screen resolution from within a Delphi 3
> program?

> BTW, a change in screen resolution would have to be reversed when the
> program exits.  It would also affect all other running programs, so it
> might not be a good solution for all cases.  My main concern is that
> it's possible to scale a lot of controls, but I have a few grids and the
> columns don't scale well.

> Thanks for input and thoughts.

--
Ken White
kwh...@westelcom.com

Clipper Functions for Delphi
http://members.aol.com/clipfunc/

Re:Change screen resolution


Quote
Alan MacArthur wrote:

> A possible solution to various screen resolutions would be a message box
> that states "This program is best viewed at 800x600.  Do you want to
> change your screen resolution to this?"  If yes, then set Screen.Width
> and Screen.Height.  Unfortunately, those are read-only variables.

This probably works, but I'm not sure if this gives a professional impression
of your app. Users kind of expect that Windows apps always work, and automatically
look out good, no matter what resolution you use. My current solution is just to
stay with 640x480 Form sizes, at least with all the most common screens.

You said that your scaled Form already now looks OK, except just some Grid
columns. How about if you make three pre settings for those grids, one for
640, second for 800 and the last for 1024 resolution. At the program start up
you check what is the user's currently selected resolution, the Screen.Width.
And then set the grid columns and dimensions according to those pre calculated
values.

If you have a lot of controls to set and calculate, this may be tedious to do,
but for a couple of bad behaving controls this could be ok. I have not tested this
myself, because there has not been absolute need for that. But if you will try it,
or someone else has used something like this succesfully, I would be glad to
hear, for my own future needs :-)

Markku Nevalainen

Other Threads