I'm trying to apply color formatting to the text in the richedit control pretty much like FrontPage used to do for the HTML text, but I don't really know how to do it.

I believe that it has to be done in a separate thread while analyzing text being typed into the control.

I tried looking at the ways to apply the coloring to the richedit text and so far I was able to find the SetSelectionCharFormat() member function that can do it, but my problem is that if I start selecting text from the background thread it will interfere with the a selection and typing.

Does anyone know how to do it?