visual c++ 6.0 编程高手中代码:// get the control size and adjust font width & height accordingly
if (m_bUse3D) rectClient.DeflateRect(3,3);
CSize textSizeClient = pDC->GetTextExtent(text,l);
if (rectClient.Width()*textSizeClient.cy >
rectClient.Height()*textSizeClient.cx)
{
logfont.lfHeight = ::MulDiv(logfont.lfHeight,
rectClient.Height(),textSizeClient.cy);
}
else
{
logfont.lfHeight = ::MulDiv(logfont.lfHeight,
rectClient.Width(),textSizeClient.cx);
}高手能帮我解释一下吗?
if (m_bUse3D) rectClient.DeflateRect(3,3);
CSize textSizeClient = pDC->GetTextExtent(text,l);
if (rectClient.Width()*textSizeClient.cy >
rectClient.Height()*textSizeClient.cx)
{
logfont.lfHeight = ::MulDiv(logfont.lfHeight,
rectClient.Height(),textSizeClient.cy);
}
else
{
logfont.lfHeight = ::MulDiv(logfont.lfHeight,
rectClient.Width(),textSizeClient.cx);
}高手能帮我解释一下吗?
LOGFONT lf;
lf.lfHeight = 15; lf.lfCharSet=GB2312_CHARSET;
VERIFY(font.CreateFontIndirect(&lf)); // create the font
SetFont(&font);
我觉得应该调整宽度而不是高度:
else
{
logfont.lfWidth = ::MulDiv(logfont.lfWidth,
rectClient.Width(),textSizeClient.cx);
}
还有会不会同时高度和宽度都不够?
你想一下就明白了 。