Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi guys,
I am writing a program to change the orientation of the display, but it failed with the error code -2(DISP_CHANGE_BADMODE), then I use the EnumDisplaySettings to enum all the settings, and find that all the display settings' dmDisplayOrientation is just DMDO_DEFAULT, but I think the settings should contain the DMDO_90,180 and 270;
here are my codes
Scroll 15:33:42
  DISPLAY_DEVICE dspDev;
	
	vector<DISPLAY_DEVICE> vectorDSP;	
	vectorDSP.clear();
	
	for (int i = 0; i < 10; i++)
	{
		memset(&dspDev, 0 , sizeof(dspDev));
		dspDev.cb = sizeof(dspDev);
		if ( ::EnumDisplayDevices(NULL, i, &dspDev, 0) == FALSE)
		{
			break;
		}

		if ( wcscmp( (WCHAR*)dspDev.DeviceName, _T("\\\\.\\DISPLAYV1") ) != 0 &&
			wcscmp( (WCHAR*)dspDev.DeviceName, _T("\\\\.\\DISPLAYV2") ) != 0 &&
			wcscmp( (WCHAR*)dspDev.DeviceName, _T("\\\\.\\DISPLAYV3" )) != 0 )
		{
			vectorDSP.push_back(dspDev);

		}

	}
	
	
	vector<DEVMODE> VectorDevMode0;
	vector<DEVMODE> VectorDevMode90;
	vector<DEVMODE> VectorDevMode180;
	vector<DEVMODE> VectorDevMode270;

	vector<DISPLAY_DEVICE>::iterator iter = vectorDSP.begin();
	for (iter = vectorDSP.begin(); iter != vectorDSP.end(); ++iter)
	{
			
			//for (int i = 0; i < 10; i++)
			{
				DEVMODE devMod;
				devMod.dmSize = sizeof(devMod);
				int i = 0;
				while (EnumDisplaySettings(iter->DeviceName,i,&devMod) != FALSE)
				{
					//devMod = devMod;
					i++;
					if (devMod.dmDisplayOrientation == DMDO_DEFAULT)
					{
						VectorDevMode0.push_back(devMod);
					}
					else if (devMod.dmDisplayOrientation == DMDO_90)
					{
						VectorDevMode90.push_back(devMod);
					}
					else if (devMod.dmDisplayOrientation == DMDO_180)
					{
						VectorDevMode180.push_back(devMod);
					}
					else if (devMod.dmDisplayOrientation == DMDO_270)
					{
						VectorDevMode270.push_back(devMod);
					}
					memset(&devMod,0 ,sizeof(devMod));
					devMod.dmSize = sizeof(devMod);
				}
			}
			
	}
Posted

1 solution

OK, I got the problem,
In the GFX driver, there is a switch, only turn on the switch to enable the rotate can the api work properly, if not it can't work properly!
 
Share this answer
 

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



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