rotate.cpp

来自「WINCE下屏幕旋转程序」· C++ 代码 · 共 66 行

CPP
66
字号
// rotate.cpp : Defines the entry point for the application.
//

#include "stdafx.h"

int WINAPI WinMain(	HINSTANCE hInstance,
					HINSTANCE hPrevInstance,
					LPTSTR    lpCmdLine,
					int       nCmdShow)
{
 	// TODO: Place code here.
//	HKEY    hRegKey;
//	DWORD   status;
//	DWORD   ValType;
//	DWORD   ValLen;

	DWORD Rotation = 0;
	DEVMODE devmode = {0}; 
	devmode.dmSize = sizeof(DEVMODE); 
	devmode.dmFields = DM_DISPLAYORIENTATION; 
	ChangeDisplaySettingsEx(NULL, &devmode, 0, CDS_TEST, NULL); 

	switch(devmode.dmDisplayOrientation)
	{
	case DMDO_0:
		devmode.dmDisplayOrientation = DMDO_90; //ˮƽģʽ 
		Rotation = 90;
		break;
	case DMDO_90:
		devmode.dmDisplayOrientation = DMDO_180;
		Rotation = 180;
		break;
	case DMDO_180:
		devmode.dmDisplayOrientation = DMDO_270;
		Rotation = 270;
		break;
	case DMDO_270:
		devmode.dmDisplayOrientation = DMDO_0;
		Rotation = 0;
		break;
	default :
		devmode.dmDisplayOrientation = DMDO_0;
		Rotation = 0;
	}

	devmode.dmFields = DM_DISPLAYORIENTATION; 
	ChangeDisplaySettingsEx(NULL, &devmode, NULL, 0, NULL); 

//	status = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
//				TEXT("System\\GDI\\Rotation"),
//				0, 0, &hRegKey);

//	if (ERROR_SUCCESS == status)
//	{
//		ValLen = sizeof(DWORD);
//		if (ERROR_SUCCESS == RegSetValueEx (hRegKey, TEXT("Angle"), NULL, REG_DWORD, (PBYTE)&Rotation, ValLen)) 
//		RegCloseKey(hRegKey);
//	}
//	RegFlushKey(HKEY_LOCAL_MACHINE);



	return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?