Solved

Changing Screen Resolution Through ChangeDisplaySetting() API

Posted on 2002-06-19
5
1,060 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
Comment Utility
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
Comment Utility
0
 
LVL 4

Accepted Solution

by:
mblat earned 100 total points
Comment Utility
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
Comment Utility
Sorry jhance, didn't mean to run on your parade....
0
 
LVL 23

Expert Comment

by:Roshan Davis
Comment Utility
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
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 video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

763 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

13 Experts available now in Live!

Get 1:1 Help Now