WTL 中使用CRichEditCtrl

先要加载dll:

HINSTANCE h_mRichEditDll;

CViewLogDlg()
{
h_mRichEditDll = ::LoadLibrary(CRichEditCtrl::GetLibraryName()); 
}

~CViewLogDlg()
{
	if(NULL != h_mRichEditDll)  
		::FreeLibrary(h_mRichEditDll);
}

(之前Create一直失败,参考这个:  http://blog.csdn.net/ludonghai715/article/details/6652729)

创建:

CRichEditCtrl   m_editView;

m_editView.Create( GetViewHWND(), NULL, NULL, 
WS_CHILD|WS_VISIBLE|WS_VSCROLL|/*WS_HSCROLL|*/ES_AUTOVSCROLL|ES_MULTILINE|ES_WANTRETURN
|WS_TABSTOP|ES_READONLY, 0, RICHEDIT_ID);

以上风格为自动换行。 

 

设定字体:

CFont  m_fntText;
m_fntText.CreateFont(13,0,0,0,FW_NORMAL,0,0,0,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY ,DEFAULT_PITCH, _T("宋体"));
m_editView.SetFont(m_fntText);


写内容:

m_editView.SetWindowText(m_strText);

你可能感兴趣的:(WTL)