CRichEditView编辑框,我的代码为什么不能改变文字颜色?
CString str;
CHARFORMAT cf;
str="1234567890";
str+="\r\n\r\n";
str+="0987654321";
GetRichEditCtrl().SetWindowText( str );
ZeroMemory(&cf, sizeof(CHARFORMAT));
cf.crTextColor = RGB(0, 255, 0);
GetRichEditCtrl().SetSel( 0,-1);
GetRichEditCtrl().SetSelectionCharFormat(cf);
CHARFORMAT cf;
str="1234567890";
str+="\r\n\r\n";
str+="0987654321";
GetRichEditCtrl().SetWindowText( str );
ZeroMemory(&cf, sizeof(CHARFORMAT));
cf.crTextColor = RGB(0, 255, 0);
GetRichEditCtrl().SetSel( 0,-1);
GetRichEditCtrl().SetSelectionCharFormat(cf);
...全文
相关推荐
关键字变色视图类
**颜色设置**:找到关键词后,使用`CRichEditCtrl`的成员函数,如`SetSelectionCharFormat`或`SetWordCharFormat`来改变对应文本的格式,包括颜色、背景色等
(MFC中)文档和视图的实现
**CRichEditView类**:扩展了CEditView,支持富文本格式,如字体、颜色、段落格式等,适合创建更复杂的文本编辑应用。
MFC如何读取rtf文件并进行展示
在实际开发中,我们可能还需要对RTF文件进行一些处理,例如修改文本、改变字体和颜色等。CRichEditView和CRichEditCtrl都提供了丰富的成员函数来实现这些功能。
test_myrichedit.zip_richedit_右键
RichEdit控件是由Microsoft开发的,通常用于需要高级文本格式化功能的应用,如文字处理软件或编程IDE。
MFC 类库参考手册
- **MFC的设计原则**:MFC的设计遵循几个基本原则,包括代码重用、易于扩展和面向对象编程等。它通过层次结构来组织类,便于理解和维护。


