Search code examples
c++c++buildervcl

how to set a custom color for a specific word like IDE


i wanna create a text field and when a user type a word it will check and if it equals to "test" for example, test's color will changes to red and so on im using c++builder, so how can it be done?


Solution

  • You can use a TRichEdit for that. You can use its SelStart and SelLength properties to select the word and then use its SelAttributes->Color property to change the word's font color (or use the Win32 API equivalents). Refer to the following article for some details about how to implement a "syntax highlighter" with TRichEdit:

    Faster rich edit syntax highlighting