tags:

views:

274

answers:

2

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 );
A: 

Try this:

int horzRes = GetSystemMetrics(SM_CXSCREEN);

int vertRes = GetSystemMetrics(SM_CYSCREEN);

Marcelo
A: 

There are definitely preconditions...

http://msdn.microsoft.com/en-us/library/ms838191.aspx says to: 1. From the Insert menu, select Resource. 2. Click the Custom button. 3. Enter CEUX for the resource type. 4. Set the resource data to 01 00. 5. Click the Properties tab. 6. Rename the item to "HI_RES_AWARE", including quotes. (If the quotes are omitted, HI_RES_AWARE will be incorrectly defined as a numeric value in resource.h, and you will need to go back and delete the line from resource.h.) 7. Deselect the external file checkbox. (whatever that means)

to enable hi resolution aware application development.

I wasn't able to create the CEUX resource that way, but I was successful after I just added it to the resource file directly, e.g.:

HI_RES_AWARE CEUX {1} // To turn off the emulation layer

The application code also needs to have an introductory:

AfxEnableDRA( true );

Even after that, all of the GetDeviceCaps values above were still zero, but

int widthX = GetSystemMetrics( SM_CXFULLSCREEN );
int heightY = GetSystemMetrics( SM_CYFULLSCREEN );
int captionHeight = GetSystemMetrics( SM_CYCAPTION );
int menuHeight = GetSystemMetrics( SM_CYMENU );
int dialogFrameWidth = GetSystemMetrics( SM_CXDLGFRAME );
int dialogFrameHeight = GetSystemMetrics( SM_CYDLGFRAME );

all returned (hi-res) values on VGA resolution PPC03se and WM5 devices and emulators.

Mike Landis