方法很多,这里讲解两种比较简单的方法,也是从google上搜索来的。
方法一:
CWnd* pEdit;
pEdit = GetDlgItem(IDC_EDIT_ONE);
ASSERT(pEdit != NULL);
HFONT hFont = (HFONT)::GetStockObject(SYSTEM_FIXED_FONT);
CFont* pFont = CFont::FromHandle(hFont);
pEdit->SetFont(pFont);
方法二:
CFont * f;
f = new CFont;
f->CreateFont(22, // nHeight
0, // nWidth
0, // nEscapement
0, // nOrientation
FW_BOLD, // nWeight
TRUE, // bItalic
FALSE, // bUnderline
0, // cStrikeOut
ANSI_CHARSET, // nCharSet
OUT_DEFAULT_PRECIS, // nOutPrecision
CLIP_DEFAULT_PRECIS, // nClipPrecision
DEFAULT_QUALITY, // nQuality
DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily
_T("Arial")); // lpszFac
GetDlgItem(IDC_EDIT_RECEIVE)->SetFont(f); //IDC_EDIT_RECEIVE是Edit框标号
方法一,方法二其实是类似的,方法二比较好,可以自由创建字体。
本文来自:我爱研发网(52RD.com) - R&D大本营
详细出处:http://www.52rd.com/blog/Detail_RD.Blog_xjl20008_7870.html