如果你想设置成另外一种字体,首先创建这种字体, CFont font; LOGFONT lf; memset(&lf, 0, sizeof(LOGFONT)); // zero out structure lf.lfHeight = 12; // request a 12-pixel-height font strcpy(lf.lfFaceName, "Arial"); // request a face name "Arial" VERIFY(font.CreateFontIndirect(&lf)); // create the font然后,使用SetFont(),设置窗口的字体。SetFont()是CWnd的成员函数,CEditCtrl是从CWnd过来的。 调用Invalidate()重绘。
你能否说得再详细些?
CFont font;
LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT)); // zero out structure
lf.lfHeight = 12; // request a 12-pixel-height font
strcpy(lf.lfFaceName, "Arial"); // request a face name "Arial"
VERIFY(font.CreateFontIndirect(&lf)); // create the font然后,使用SetFont(),设置窗口的字体。SetFont()是CWnd的成员函数,CEditCtrl是从CWnd过来的。
调用Invalidate()重绘。
( CMyRichEditCtrl : public CRichEditCtrl )
CMyRichEditCtrl m_RichEditCtrl;m_RichEditCtrl.Create( WS_CHILD | WS_VISIBLE | ES_MULTILINE | ES_WANTRETURN , rectD, pParentWnd, nID);在创建后使用下面的函数:
m_RichEditCtrl.SetReadOnly();
m_RichEditCtrl.EnableWindow(FALSE);m_RichEditCtrl.SetWindowText(......);
显示内容变灰,不能编辑,但仍旧可以改变字体(名称、大小、Bold, Italic, underline...)、段落格式等。我不能给你源码,可以给你截屏。