获取 WinCE 移动设备屏幕旋转方向
2016-02-21 16:06
351 查看
获取 WinCE 移动设备屏幕旋转方向,分别从系统提供的接口和注册表获取。如果都获取不到,则采用默认值。
#ifndef DMDO_ZERO #define DMDO_ZERO 0 #endif #ifndef DMDO_90 #define DMDO_90 1 #endif #ifndef DMDO_180 #define DMDO_180 2 #endif #ifndef DMDO_270 #define DMDO_270 4 #endif //direction flags #define DIR_SWAPXY 0x001 #define DIR_MIRRORLEFTRIGHT 0x002 #define DIR_MIRRORUPDOWN 0x004 static int giOrientation = -1; #define TARGET_WINCE int GetOrientation() { #if defined(TARGET_WINCE) if(giOrientation < 0) { HKEY Key; // context *p = NULL; char Buffer[256]; DEVMODE *Mode = (DEVMODE *)Buffer; // 一个比较复杂的结构体, 定义请参看 MSDN Mode->dmSize = 192; Mode->dmFields = 0x01000000L; static LONG (WINAPI *FuncChangeDisplaySettingsEx)(LPCTSTR,LPDEVMODE,HWND,DWORD,LPVOID) = NULL; HINSTANCE CoreDLL = LoadLibrary(_T("coredll.dll")); if (CoreDLL) { *(FARPROC *)&FuncChangeDisplaySettingsEx = GetProcAddress(CoreDLL,_T("ChangeDisplaySettingsEx")); } if(FuncChangeDisplaySettingsEx && 0 == FuncChangeDisplaySettingsEx(NULL, Mode, NULL, CDS_TEST, NULL)) { Mode->dmFields = 0x00800000L; FuncChangeDisplaySettingsEx(NULL, Mode, NULL, CDS_TEST, NULL); switch((&Mode->dmDisplayFrequency)[1]) //(Mode->dmDisplayOrientation) { case DMDO_ZERO: giOrientation = 0; break; case DMDO_90: giOrientation = DIR_SWAPXY | DIR_MIRRORUPDOWN; break; case DMDO_270: giOrientation = DIR_SWAPXY | DIR_MIRRORLEFTRIGHT; break; case DMDO_180: giOrientation = DIR_MIRRORUPDOWN | DIR_MIRRORLEFTRIGHT; break; default: // giOrientation = 0; break; } } if(giOrientation < 0 && ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("System\\GDI\\ROTATION"), 0, KEY_READ, &Key)) { DWORD dwValue; DWORD dwRegSize = sizeof(dwValue); DWORD dwRegType; if(ERROR_SUCCESS == RegQueryValueEx(Key, _T("Angle"), 0, &dwRegType, (LPBYTE) &dwValue, &dwRegSize)) { switch(dwValue) { case 0: giOrientation = 0; break; case 90: giOrientation = DIR_SWAPXY | DIR_MIRRORUPDOWN; break; case 270: giOrientation = DIR_SWAPXY | DIR_MIRRORLEFTRIGHT; break; case 180: giOrientation = DIR_MIRRORUPDOWN | DIR_MIRRORLEFTRIGHT; break; default: // giOrientation = 0; break; } } RegCloseKey(Key); } if(giOrientation < 0) giOrientation = 0; } #else giOrientation = 0; #endif RETAILMSG(1,(L"[%s]Orientation: %d\r\n",CString(__FUNCTION__),giOrientation)); // [GetOrientation]Orientation: 0 return giOrientation; }
相关文章推荐
- git相关知识学习
- hdu 3979 Monster【贪心】
- android 开发技巧(3)--创建定制的 ViewGroup
- 深入理解计算机系统-之-数值存储(四)--整数在内存中的存储方式
- C#对象转json字符串和json字符串转对象
- 游戏服务器
- WinCE 下进程可访问的代码页的地址获取
- php curl参数详解
- poj 2406 Power Strings(KMP)
- Objc中为何某些类的属性要设置为copy而不是strong?
- Objc中为何某些类的属性要设置为copy而不是strong?
- uva1646
- Java中怎么获取键盘输入-Scanner
- Objc中为何某些类的属性要设置为copy而不是strong?
- linux内核学习之总线、驱动、设备、kset、kobject
- Telechips 8902 & WinCE6.0 平台下 overlay 使用冲突现象的分析
- HDU 3046 Pleasant sheep and big big wolf(最小割)
- graphics
- jQuery全屏滚动插件fullPage.js
- 详解IOS中GCD的使用