Click here to Skip to main content
15,890,185 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Progaram for Changing the display setting:


#include "stdafx.h"
#include <stdio.h>

#define WINVER 0x0501
#define WIN32_LEAN_AND_MEAN
#include <windows.h>

int main(int argc, char* argv[])
{
	DEVMODE dm;
	
	ZeroMemory(&dm, sizeof(dm));
	
	dm.dmSize = sizeof(dm);
   
   if (0 != EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm))
   {


     dm.dmPelsHeight= 800;
     dm.dmPelsWidth = 600;

	 dm.dmDisplayOrientation = DMDO_180;

	 dm.dmFields =  DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYORIENTATION;
	 
	 if(DISP_CHANGE_SUCCESSFUL  == ChangeDisplaySettings(&dm,0))
	 {
		 printf("\nSuccess\n");
	 }
	 else
	 {
		 printf("\nFailure\n");
	 }
   }
   return 0;
}


It works fine.
if i try for the 90 and 270 rotation means it fine.
But if i try 0 and 180 means it goes to failure .
Please give the solution for me.

[edit]Code block added to preserve format, and remove HTML tag processing - OriginalGriff[/edit]
[edit]Missed the added closing tags - doh! - OriginalGriff[/edit]
Posted
Updated 1-Nov-11 22:37pm
v4
Comments
Amir Mahfoozi 2-Nov-11 2:38am    
Try your code on other type of monitors to find out it depends on your code or your monitor.
@BangIndia 2-Nov-11 2:49am    
ok. sir..
@BangIndia 2-Nov-11 2:52am    
in other machine also same sir..


ChangeDisplaySettings actually returns a value saying what went wrong. Instead of checking for the successful result only try using a switch with something more than just 'Failure'. If you check the docs the possible return values are:
DISP_CHANGE_SUCCESSFUL
DISP_CHANGE_BADDUALVIEW
DISP_CHANGE_BADFLAGS
DISP_CHANGE_BADMODE
DISP_CHANGE_BADPARAM
DISP_CHANGE_FAILED
DISP_CHANGE_NOTUPDATED
DISP_CHANGE_RESTART 
 
Share this answer
 
If 90 and 270 degrees work it could just be that the device isn't capable to do it. You could check it out using the CDS_TEST flag using ChangeDisplaySettingsEx. (or with the result in dm after you call EnumDisplaySettings)
http://msdn.microsoft.com/en-us/library/aa452713.aspx[^]

Good luck!
 
Share this answer
 
Comments
@BangIndia 2-Nov-11 5:35am    
if i declare DMDO_0 it produce error sir..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900