Rich Text Edit – Syntax Highlighting

Rich Text Edit – Syntax Highlighting

I’m building an application where the user can type several lines of text and save it to disk (as plain text). It would be nice if some words appeared in other colors for emphasis. This is something like syntax highlighting you can find in Powerbuilder itself. If I want to implement this, where should I check for these special words, and how can I adjust the properties of that text only?

To implement syntax highlighting, it’s best to use the Rich Text Edit Control. Loop through the lines of text in the control looking for the words you want to highlight.

When you have identified the text you want to highlight, use the RTE command SelectText to select the text inside the control. Then use the RTE command SetTextColor to change the color of that item of text. Be aware that the RTE supports only the basic 16 windows colors?for example, 255 for red and 127 for dark red.

See also  Does It Make Sense to Splurge on a Laptop?

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist