CRichEditCtrl控件的使用方式 追加显示

常规的EDIT控件只能显示一行,当我们希望把所有的操作日志都显示出来,此时你应该选择RICHEDIT控件;

1、初始化此控件: AfxInitRichEdit2();

2、设置显示内容:用以下接口即可不断追加显示操作日志

bool PirntLog(char* pszLog)
{
       m_ctrlRichShow.ReplaceSel(pszLog);//追加显示的内容
       return true;
}

注意:

①、在输入参数pszLog参数后添加\n换行符,输入的显示会自动换行;
②、设置控件属性可以垂直拉动,vertical scroll =True即可上下拉动显示全部内容;

 

ReplaceSel接口的解释:

 

CRichEditCtrl::ReplaceSel

void ReplaceSel( LPCTSTR lpszNewText, BOOL bCanUndo = FALSE );

Parameters

lpszNewText

Pointer to a null-terminated string containing the replacement text.

bCanUndo

To specify that this function can be undone, set the value of this parameter toTRUE. The default value is FALSE.

Remarks

Call this function to replace the current selection in this CRichEditCtrl object with the specified text. To replace all the text in thisCRichEditCtrl object, use CWnd::SetWindowText.

If there is no current selection, the replacement text is inserted at the insertion point, that is, the current caret location.

 

你可能感兴趣的:(总结)