Last active
February 24, 2016 11:58
-
-
Save NPatch/926a0755398ac985b07b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//MUST have a valid window created to obtain a correct HMONITOR from the window's hWnd. Console windows don't give a correct HMONITOR. | |
//Neither did it work by calling GetConsoleWindow to get a hWnd for a console application and querying the HMONITOR from the console hWnd. | |
//Monitor from Window | |
HMONITOR monitor_handle = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST); | |
MONITORINFOEX monitor_info; | |
monitor_info.cbSize = sizeof(MONITORINFOEX); | |
GetMonitorInfo(monitor_handle, &monitor_info); | |
DEVMODE devmode; | |
EnumDisplaySettings( | |
monitor_info.szDevice, | |
ENUM_CURRENT_SETTINGS, | |
&devmode | |
); | |
switch (devmode.dmDisplayOrientation){ | |
case DMDO_90: | |
//Portrait | |
break; | |
case DMDO_180: | |
//Landscape(Flipped) | |
break; | |
case DMDO_270: | |
//Portrait(Flipped) | |
break; | |
default: | |
//Landscape | |
} | |
//Display name is monitor_info.szDevice and Orientation comes from the above switch in whichever form we need |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment