Solved

Changing Screen Resolution Through ChangeDisplaySetting() API

Posted on 2002-06-19
5
1,065 Views
Last Modified: 2013-12-03
Hello Experts,

I have made a Win32 GDI Application which runs only in 800*600 Resolution.

I want, when the applicaton runs, if the display settings are other than 800*600, say 1K or might be 640*480, instead of user doing it manually, I want doing it my self through win32 code of the application.

Searching across MSDN I found changedisplaysetting and changedisplaysettingex and other device capable functions, but was not able to achieve the results.

Can anyone tell me exactly, how it can be done from these win32 device-capable API'S.
Also I just want to change the resolution of the screen and nothing else, such as refresh frequency, bit-rate etc.

Please suggest as how to do it.

Best Regards
Austin

0
Comment
Question by:austin123
  • 2
  • 2
5 Comments
 
LVL 32

Expert Comment

by:jhance
ID: 7093721
The display resolution is inter-related with the refresh frequency.  You cannot change one without regard to the other.

You must:

1) Use EnumDisplaySettings to find a permissible display setup for this adapter/display combo.

2) Use ChangeDisplaySettings to actually change the display mode.

I also strongly suggest that you RESTORE the original display setting for the user when you exit your application.
0
 
LVL 32

Expert Comment

by:jhance
ID: 7093729
0
 
LVL 4

Accepted Solution

by:
mblat earned 100 total points
ID: 7093742
Can you post your code?

The following works fine on mine Win2K laptop...

    DEVMODE dm;

    dm.dmSize = sizeof(DEVMODE);
    dm.dmDriverExtra = 0;
    EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS,&dm);
    dm.dmPelsHeight = 600;
    dm.dmPelsWidth  = 800;
    ChangeDisplaySettings(&dm,0);


Hope it helps....
0
 
LVL 4

Expert Comment

by:mblat
ID: 7093744
Sorry jhance, didn't mean to run on your parade....
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 7094797
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

860 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