MFC 编辑框 派生对话框类和使用 SetFont() 成员函数
2013-06-01 14:42
387 查看
下面的代码演示如何从 CModalDialog 派生对话框类和使用 SetFont() 成员函数:
原文地址
/* * Compiler options needed: None */ class CMyAboutBox : public CDialog { CFont m_font; public: // Constructor -- This code assumes a dialog box // template named "ABOUTDLG" in the application's .RC file. CMyAboutBox(CWnd* pParentWnd = NULL) : CModalDialog("ABOUTDLG", pParentWnd) {}; BOOL OnInitDialog(); }; // OnInitDialog() function -- Called after Windows creates // the dialog box but before it is painted on the screen. BOOL CMyAboutBox::OnInitDialog() { LOGFONT lf; // Used to create the CFont. CDialog::OnInitDialog(); // Call default ::OnInitDialog memset(&lf, 0, sizeof(LOGFONT)); // Clear out structure. lf.lfHeight = 20; // Request a 20-pixel-high font strcpy(lf.lfFaceName, "Arial"); // with face name "Arial". m_font.CreateFontIndirect(&lf); // Create the font. // Use the font to paint a control. This code assumes // a control named IDC_TEXT1 in the dialog box. GetDlgItem(IDC_TEXT1)->SetFont(&m_font); return TRUE; }
原文地址
相关文章推荐
- 如何在MFC线程中使用控件的成员变量和函数
- C++ MFC 其他函数获得主对话框指针并使用成员的方法
- 信息: 更正 SetFont() 函数,在 MFC 的使用 修改字体
- mfc 获取主对话框指针(在全局函数中使用对话框类函数)
- MFC-CString类及其成员函数使用实例
- MFC中的cstring成员函数使用
- 在 MFC 中的 SetFont() 函数的正确使用
- 类的静态成员函数和静态成员变量的使用
- 第十周刷OJ题 统计程序设计基础课程学生的平均成绩(静态成员函数的使用复习)
- C++中使用空对象指针调用成员函数
- 类的静态成员函数和静态成员变量的使用
- “error C3867: “XXX”: 函数调用缺少参数列表;请使用“&XXX”创建指向成员的指针”的错误
- Item 45:使用成员函数模板来接受所有兼容的类型
- MFC中UpdateData()函数的使用 .
- 成员函数后面加const,没有const,以及使用的区别
- MFC中使用函数的简略笔记
- C++中各种数据成员及成员函数的定义及使用
- [5.19]设计一个虚基类base,包含姓名和年龄私有数据成员以及相关的成员函数;由它派生出领导类leader,包含职务和部门私有数据成员以及相关的成员函数;再由base派生出工程师类engieer,
- 尽量使用区间成员函数代替它们的单元素兄弟
- 静态成员变量和静态成员函数的使用