A quick guess as to how to make the resolution dynamic:
// Get the device context of the screen
HDC hScreenDC = CreateDC(_T("DISPLAY"), NULL, NULL, NULL);
int cxWidth = GetDeviceCaps(hScreenDC, HORZRES); // cxWidth or GetSystemMetrics(SM_CXFULLSCREEN);
int cyHight = GetDeviceCaps(hScreenDC, VERTRES); // cxHeight or GetSystemMetrics(SM_CYFULLSCREEN);
// cbxPitch [number of bytes to move right one x pixel, can be negative]
// cbyPitch [number of bytes to move down one y pixel, can be negative]
int cBPP = GetDeviceCaps(hScreenDC, BITSPIXEL); // bpp
int ffFormat = (kfDirect | kfDirect565); // format
BOOL bBuffer = TRUE // bDRAMBuffer
DeleteDC(hScreenDC);
// Configuration, select what you want from above list
Config l_config = { cxWidth, cyHeight, 480, -2, cBPP, ffFormat, bBuffer };
I am not sure how to ascertain programmatically if there is a screen buffer or what the format and pitch are. They are supposed to come out of GXGetDisplayProperties, but obviously this is being stubbed by this fake DLL. WinCeSoft uses a configuration database in the GAPI settings.
As for the cb Pitch values, currenty I'm vague on the maths on that one to even begin to guess. Anyone here understand how it is defined?
cxWidth
The number of visible pixels across the display. Width is considered the left to right measurement when looking at the physical device.
cyHeight
The number of visible pixels along the height of the display.
cbxPitch
The number of bytes to add to move a pointer to the right one pixel. See note below about display depths that are less than 8 bpp.
cbyPitch
The number of bytes to add to move a pointer down one pixel. See note below about display depths that are less than 8 bpp.
cBPP
The number of bits per pixel. Always a power of 2.
ffFormat
Information about the display format. Code member is one of the following format flags.
Flag Description:
KfLandscape
Display is oriented on its side. 0,0 is in the lower-left corner; increasing addresses move up the screen. Generally, it is not an issue if you use cbxPitch and cbyPitch. See Remarks below about display depths that are less than 8 bpp.
KfPalette
Display is palette based.
KfDirect
Display is direct mapped, no palette. This is a "helper" bit, so you do not have to check all the direct flags manually.
KfDirectInverted
Indicates the display colors are inverted. For example, with black and white colors, white is black.
kfDirect555
kfDirect565
kfDirect888
Format of a direct mapped pixel. Numbers specify bits per color in red-green-blue order. The Intel byte order is assumed: for kfDirect565 a
left shift of 11 will put the low-order bits of a short or long into the red position.