Solved

Setting the screen resolution

Posted on 2001-09-14
10
178 Views
Last Modified: 2013-11-20
Hey,

     I was wondering if there was a way to actually set the screen resolution, eg. to 1024x720, from C++, in a way that would be compatible with MFC?  I know there's a way to get what the current settings are, but I haven't figured out how to actually set the settings.

     Sample source greatly appreciated.

     Thanks in advance.
0
Comment
Question by:fcp_lead
10 Comments
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 100 total points
ID: 6484345
You could warn the user then start up the windows desktop applet if the screen resolution doesn't fit your App's requirements.
Use "CONTROL.EXE DESK.CPL" as the parameters of the new process.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6484366
You can get a little closer to the target by execing:

  RUNDLL32.EXE shell32.dll,Control_RunDLL desk.cpl,,3

Try it from the Start/Run... command.

I'd like to add that...
even if you can find a way to change the system screen resolution programmatically, it would be a *very bad* idea.   Those kinds of decisions need to be made by the user and/or the system administrator.  A wrong setting can kill Windows until a technical expert can get around to fixing things.

-- Dan
0
 
LVL 32

Expert Comment

by:jhance
ID: 6484521
I'd be interested to know how to do this as well...

It's my understanding that there is no Windows API to do this and that the DISPLAY driver itself implements some method (if needed) to control the resolution and that the mechanism by which it is controlled is therefore up to the individual driver maker.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

 
LVL 1

Expert Comment

by:MRNMurthy
ID: 6484594
Hi,

I don't it is programmatically posible, I will try once.

From

MRN Murthy
0
 
LVL 1

Expert Comment

by:TarekEslim
ID: 6485543
In MFC, you can use the function: ChangeDisplaySettings and/or ChangeDisplaySettingsEx

It uses the DevMode structure parameter. It includes all properties about devices (Display, Printer, ...)

The function GetDeviceCaps retrieve the device information (Display device also)

See the MSDN help on these commands you will find full details.

Regards

Tarek
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 6486742
Further to my first post.  I would NOT recommend trying to change the settings yourself, let the user have the option to do so if they wish.  (I hate programs that alter MY setup of MY workstation without asking for permission.)

If you need to have the setting changed then you can start the display applet with createprocess and monitor the process until it finishes then recheck the settings.  If not suitable then fail gracefully.
If you need some code to do this creating/waiting then I can dig some up for you from one of my apps.

Any further questions?
0
 

Expert Comment

by:a_mellouk
ID: 6511890

This is the way to do it
exemple

CDC *pDC = GetDC();
int Hor = pDC->GetDeviceCaps(HORZRES);

if (Hor < 1024)
 //yor code
 .
 .
 .

ReleaseDC(pDC);
//see MSDN for aditional information
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6802878
hi fcp_lead,
Are you still interested in this question?  If so, you must reject the nonesense answer propose by a_mellouk so that other experts will comment.

a_mellouk,
Please post comments like everybody else.  Also, take a moment and read the questions before proposing anything at all.  Thanks!

-- Dan

0
 
LVL 11

Expert Comment

by:griessh
ID: 7202241
Unless there is objection or further activity,  I will suggest to accept

     "AndyAinscow"

comment(s) as an answer.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
0
 
LVL 6

Expert Comment

by:Mindphaser
ID: 7220578
Force accepted

** Mindphaser - Community Support Moderator **
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

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

Suggested Solutions

Title # Comments Views Activity
repeatEnd java challenge 42 85
string initialization in java 11 115
fix34  challenge 9 143
moto 4g phone enable finger print 4 26
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

837 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