Search code examples
xmlvisual-c++mfcsyntax-highlightingcedit

Can we use XSL / XML syntax highlighting with CEdit control?


MFC Visual C++ Dialog

I have a standard multiline CEdit control:

enter image description here

It displays XSL script. It is possible to display this using one of the standard syntax highlighter colour schemes?


Solution

  • Nope, standard edit controls have no functions or messages to set the color (or even the font) for a part of the displayed text. So the solution could be either an owner-drawn control (you will need to implement everything yourself) or maybe a rich-edit control (then you will have to convert the xml text to rich text). Take a look at this post.

    Also, syntax highlighting is content- (language-) specific, plus which are those "standard" color schemes? And this is not a trivial task anyway. You need a lot of processing, ie syntax analysis and mapping to the colors of the scheme. I'm not aware of any Win32 facilities that perform this. Maybe you can check if the sources of a tool like Notepad++ are available in some repository and take a look, if this is worth (for your application). Probably you will have to load plugins for the syntax analysis task.