Windows Mobile GetDeviceCaps always returns zero

windows-mobile

Is there a precondition to calling GetDeviceCaps? I'm trying to discover (at run-time) whether the native screen resolution for a Windows Mobile device is QGVA or VGA. The following return values are all zero in OnInitDialog():

CDC* dc = GetDC();
int horzRes = GetDeviceCaps( HDC(dc), HORZRES );
int vertRes = GetDeviceCaps( HDC(dc), VERTRES );
int xLogPixels = GetDeviceCaps( HDC(dc), LOGPIXELSX );
int yLogPixels = GetDeviceCaps( HDC(dc), LOGPIXELSY );

Best Answer

Try this:

int horzRes = GetSystemMetrics(SM_CXSCREEN);

int vertRes = GetSystemMetrics(SM_CYSCREEN);

Related Topic