Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Setting the screen resolution

Posted on 2001-09-14
10
Medium Priority
?
183 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
[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
10 Comments
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 400 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
Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

 
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

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

719 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