超高分辨率下的MFC对话框控件

时间:2015-03-05 20:22:51

标签: mfc dialog controls spacing high-resolution

在超高分辨率环境中使用我的应用程序时,我遇到了对话框控件的间距和大小问题。我在for循环中使用以下代码放置控件:

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

然而,超高分辨率图像显示为: Ultra Res

高分辨率图像为: Normal Res

1 个答案:

答案 0 :(得分:2)

您需要考虑字体的大小。

CFont* pFont = GetFont();

LOGFONT lf;
pFont->GetLogFont(&lf);

int iFontHeight = lf.lfHeight; // use this + padding to space your controls vertically

如果您想了解有关字体的更多详细信息,可以使用GetTextMetrics()。