16,551
社区成员
发帖
与我相关
我的任务
分享
void C****View::OnDraw(CDC* pDC)
{
// TODO: Add your specialized code here and/or call the base class
LOGFONT logFont;
ZeroMemory((void*)&logFont,sizeof(logFont));
lstrcpy(logFont.lfFaceName,_T("Times New Roman"));
logFont.lfHeight = -12;
logFont.lfWeight = 400;
logFont.lfCharSet = SHIFTJIS_CHARSET;
logFont.lfOutPrecision = 3;
logFont.lfClipPrecision = 2;
logFont.lfQuality = 1;
logFont.lfPitchAndFamily = 2;
m_font.CreateFontIndirect(&logFont); //m_font是成员变量
SetFont(&m_font);
// 设置字体
/* CFont* pFont = GetFont();
LOGFONT lf;
if (pFont != NULL)
pFont->GetObject(sizeof(LOGFONT), &lf);
else
::GetObject(GetStockObject(SYSTEM_FONT), sizeof(LOGFONT), &lf);
CFontDialog dlg(&lf, CF_SCREENFONTS|CF_INITTOLOGFONTSTRUCT);
if (dlg.DoModal() == IDOK)
{
// switch to new font.
m_font.DeleteObject();
if (m_font.CreateFontIndirect(&lf))
{
CWaitCursor wait;
SetFont(&m_font);
}
}
*/
}
CHARFORMAT2 cf2;
memset(&cf2, 0, sizeof(CHARFORMAT2));
cf2.cbSize = sizeof(CHARFORMAT2);
cf2.dwMask = CFM_FACE ;
_tcscpy(cf2.szFaceName, _T("Times New Roman"));
::SendMessage(m_hWnd, EM_SETCHARFORMAT, 0, (LPARAM)&cf2);