Is there any way to poll the actual physical aspect ratio (or even the dimensions) of the display device (not the display mode resolution - the screen itself)? ...and would the method work correctly despite the correct driver being installed for the monitor? I'm looking for Win32 API calls that will work with all Win32 platforms.
问问题
452 次
1 回答
0
This is the closest I could come up with, using GetDeviceCaps() to determine the aspect ratio of the device corresponding to the desktop DC. A snippet from my code...
HDC hDC = GetDC(NULL);
if (hDC != NULL)
{
float dw = (float)GetDeviceCaps(hDC, HORZSIZE);
float dh = (float)GetDeviceCaps(hDC, VERTSIZE);
ReleaseDC(NULL, hDC);
// Equivalent of reducing a fraction
if (dw > dh)
{
dw /= dh;
dh = 1.0f;
}
else
{
dh /= dw;
dw = 1.0f;
}
wcp.fAspectNumerator = dw;
wcp.fAspectDenominator = dh;
}
于 2013-10-29T15:57:12.407 回答