I am having trouble with the spacing and size of dialog controls when using my application in an ultra high resolution environment. I place the controls using the following code in a for loop:
GetClientRect(cRectDimen);
int iHalf = cRectDimen.right / 2;
int iY = cRectDimen.top;
int iX = cRectDimen.left+5;
int iVeryFarRight = cRectDimen.right - 5;
int iFarRight = iHalf - 10;
POINT ptTop,ptBottom;
cStat = new CStatic;
iY += 20;
ptTop.x = iX + 10;
ptTop.y = iY;
ptBottom.x = iX + pDataField->m_csDesc.GetLength() * 10;
ptBottom.y = iY + 15;
cStatRect.SetRect(ptTop,ptBottom);
Yet the ultra high resolution image appears as:
And the high resolution image as:
You need to take in account the size of the font.
CFont* pFont = GetFont();
LOGFONT lf;
pFont->GetLogFont(&lf);
int iFontHeight = lf.lfHeight; // use this + padding to space your controls vertically
If you want to get more detail on the font, you can use GetTextMetrics().