[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 185
  • Last Modified:

Setting the screen resolution

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
fcp_lead
Asked:
fcp_lead
1 Solution
 
AndyAinscowFreelance programmer / ConsultantCommented:
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
 
DanRollinsCommented:
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
 
jhanceCommented:
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
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
MRNMurthyCommented:
Hi,

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

From

MRN Murthy
0
 
TarekEslimCommented:
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
 
AndyAinscowFreelance programmer / ConsultantCommented:
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
 
a_melloukCommented:

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
 
DanRollinsCommented:
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
 
griesshCommented:
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
 
MindphaserCommented:
Force accepted

** Mindphaser - Community Support Moderator **
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now