M FC 编辑框如何改变字体的大小 方法一: 步骤一:在Dlg 类中增加一个类成员变量: CFont m_editFont; 注意:这里Font 对象必须是类成员变量,不能是局部变量,否则会出现只改变了光标的大小,而不能改变字体的大小
步骤二:在OnInitDialog 方法中增加下列语句: m_editFont
CreatePointFont(180, "宋体"); m_editPlace
SetFont(&m_editFont); // 设置新字体 方法二: 在OnInitDialog 方法中增加下列语句也可以实现: CFont* ptf=m_editPlace
GetFont(); // 得到原来的字体 LOGFONT lf; ptf->GetLogFont(&lf); lf
lfHeight = 20; // 改变字体高度 strcpy (lf
lfFaceName, "隶书"); // 改变字体名称 m_editFont
CreateFontIndirect(&lf); m_editPlace
SetFont(&m_editFont); // 设置新字体 注意:If 是个新的结构体变量,GetLogFont 函数是实现将 ptf 中的LOGFONT 结构体变量拷贝给 If 了,所以改变If 不等于是改变ptf 中的LOGFONT 变量
所以下面必须加这两句来创建新的字体对象 m_editFont
CreateFontIndirect(&lf); m_editPlace
SetFont(&m_editFont); // 设置新字体 CFont font; LOGFONT lf; memset(&lf, 0, sizeof(LOGFONT)); // zero out structure lf
lfHeight = 12; // request a 12-pixel