C++ Builder 语法荧光笔

C++ Builder Syntax Highlighter

我已经在互联网上搜索过如何执行此操作,但找不到如何执行此操作。

我需要在 RichEdit 中为特定的单词着色,例如 falsetrue.

TRichEdit 不太适合语法高亮显示(直接使用更像 SynEdit instead), but it can be done. Basically, you need to highlight the desired text, and then set the selected text's attributes, like color and formatting. You can do that with the TRichEdit::SelStart, TRichEdit::SelLength, and TRichEdit::SelAttributes properties. Or you can use the corresponding Win32 API EM_EXSETSEL and EM_SETCHARFORMAT 消息的东西。

请参阅 Robert Dunn 关于此主题的精彩文章:"Faster Rich Edit Syntax Highlighting"。 Original article first appeared in the C++Builder Journal in October 1999, and is also available for download on Robert's "Yet Another Code Site" 网站(存档在我的网站上)。