Solved

Changing Screen Resolution Through ChangeDisplaySetting() API

Posted on 2002-06-19
5
1,063 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

919 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now