VC设置LOGFONT后字体没有变化
OnCreate:
m_strFont.Format("%s",FontWantedByUser(font_index));
LOGFONT lf;
pElement->GetLogFont(&lf);
_tcscpy(lf.lfFaceName, m_strFont);
pElement->SetFont(&lf);
void CxStatic::SetFont(LOGFONT *pLogFont, BOOL bRedraw /*= TRUE*/)
{
ASSERT(pLogFont);
if (!pLogFont)
return;
if (m_font.GetSafeHandle())
m_font.DeleteObject();
LOGFONT lf = *pLogFont;
m_font.CreateFontIndirect(&lf);
if (bRedraw)
RedrawWindow();
}
CDC *dc = this->GetDC();
CFont* pFont = dc->GetCurrentFont();
LOGFONT logFont ;
pFont->GetLogFont(&logFont);
strncpy(logFont.lfFaceName,"Arial",LF_FACESIZE-1);
logFont.lfFaceName[LF_FACESIZE-1]=0;
logFont.lfHeight = -32;
HFONT hFont = CreateFontIndirect(&logFont);
dc->SelectObject(hFont);
dc->TextOut(100,100,"bbbbbbb");