Assume I have a plain-text file of numbers and I want to display this file in a RichEdit control with different numbers in different colors or styles.

What I was considering was using EM_STREAMIN and setting the value of the EditStreamCallback's cb param (count of bytes) to 1 so that I can check the value of the byte and use EM_SETCHARFORMAT to change the format before sending it to the control.

However, with a large file, this would seem to be a long-winded way of going about it.

Are there any other (faster\more sensible) ways of achieving what I'm after?

Thanks for any suggestions

Posted on 2006-08-06 12:17:09 by Not-A-Clue
You could just change the colors for the visible portion of the text file in the richedit..
Posted on 2006-08-06 12:20:24 by lone_samurai5
Hi and thanks ;-)

I understand what you mean about only setting the visible portion as opposed to the whole file, but when you say

...change the colors...

do you mean in the way I suggested (EM_STREAMIN & EM_SETCHARFORMAT) or are you thinking of a different method?

Thanks again

Posted on 2006-08-06 14:31:43 by Not-A-Clue

What I do is construct my own .RTF file from the raw text of the report I create.

1) Create a new file with the appropriate name ie. Report.RTF

2) Write to this file the appropriate RTF header:
	rtf1			db	"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}}", 13, 10
sizeof.rtf1 = $ - rtf1
rtf25 db "\viewkind4\uc1\pard\b\f0\fs20 "
sizeof.rtf25 = $ - rtf25

3) Set up tab definitions if necessary:
	rtf_tab_bo			db	'\pard\tx1600\tx2800\tx4100\tx5400\tx6400\tx7700\tx9000\tx10300\tx11600\tx12900 '
sizeof.rtf_tab_bo = $ - rtf_tab_bo

4) Write text with any formatting necessary: See attachment, Created with WordPad, open with notepad or other plain text editor.

5) End of document:
	rtf_end				db	"\par }", 13, 10
sizeof.rtf_end = $ - rtf_end

Search for RTF content reference! ie


Posted on 2006-08-06 14:50:35 by farrier
well not that method.. check out http://win32assembly.online.fr/tut35.html.. :)
Posted on 2006-08-06 20:54:56 by lone_samurai5

Thanks for all the pointers  ;)
I had started with the idea of pre-formatting into rtf and had already downloaded the RTF specs. I only wanted to highlight some text and it looked like learning another language, lol. Anyway, it left me with the problem of indexing back into the original text file after user input. Probably just too much going on in this poor ol' head at the one time  :oops:


Thanks again for your help. I only had the FASM converted versions of Iczelion's tuts, which don't go up to 35  :sad:. I like Icz's method of using WM_PAINT so I'll read it a bit further and see if I can get what I need  ;)

Posted on 2006-08-07 05:05:41 by Not-A-Clue