HI , I m stuck fsince past month ,I m using default richeditctrl in richeditview.
my requirement is that i want to show colored traces in every10 milliseconds.But i m struggling to do so,
i have seen various examples and tutorials online, but can,t achieve it.
And you really have to do that every 10ms? That's just too fast, and overkill anyway. 10ms is 100 FPS, that's too fast to read. You could update the text at a much lower FPS , that's more than fast enough for scrolling text.
So, I suggest you buffer your traces and only update the richedit say every 100 ms for example (that's still 10 updates per second, more than fast enough I think). Based on the results of the 100ms update rate, you can slow it down even more, or speed it up a bit.
my requirement is that i want to show colored traces in every10 milliseconds.
Is this ultimately your requirement or your want?
Besides, 10 ms is very short interval for any kind of iterative drawing in Windows, and I doubt that common controls are able to operate/react that fast. FYI, Windows workstation editions have 10 ms interval as a single dispatching time slot, and server editions have 25 ms for that. Windows is definitely not a Real Time OS.
i have seen various examples and tutorials online, but can,t achieve it.
How this is supposed to help us to understand your problem?
What i understood is that,If I can do this buffering my problem will be actully solved.
But the question for me is ,how to buffer a richedit that is having text of various colors...
Can I use a Cstring or any method ??
CString doesn't contain any formatting.
I don't know what kind of input you get for your traces.
Can't you just store the input in a buffer instead of directly in the richedit?
Marg, actually traces are generated in my application in random order, they contain date , time the data and error code etc,
I want errors , acknowlegement and warning trace to be printed in different color, now what kind of intermediate buffer should i use that can hold the formatting ???
Create a small class that contains the message itself and some enumeration that specifies whether it's a warning, info, or error.
When a message comes in, create an instance of that class and store it in a queue.
Ya marg , I actually already stored the lines in a queue using structuresanf calling "ReplaceSel(str);" from thread, but the problem is all the lines of that buffer have
same formatting(same color)..for all lines inside buffer ,that i called last using mfc function for richeditctrl "SetSelectionCharFormat(cf)";
Richedit does extensive parsing of the input in order to draw a wide variety of different text. This processing of the 'RTF language' takes time. Making richedit unsuitable for fast trace output.
RichEdit is also limited in what you can do, afaik, background color isn't possible.
You will either need to create your own control that is tailored to your needs, in which case you can make it fast enough to handle 10ms response times.
Or you could subclass another control that resembles what you need and change part of the behaviour.
A Listbox or a listcontrol are suitable examples which you can use to do trace output. (however with the limitation that selecting items is on a row by row basis rather than a character by character basis as in a richedit.
It is possible to make a listbox/listcontrol have each row in a color of choice, and even colorize a single row in multiple colors (with some more work).
OReubens is right, you could create your own control, but even then, I don't think it makes sense to update text on the screen at 100 frames per second. That's just overkill.
I would still try to simply store your messages in a queue and only update the RTF control 10 times per second or even less. I don't understand the difficulty with this solution. You have the message strings, you know if it's an error, info, or whatever kind of message. If you store this information in a queue, you can then every 100ms or so check the queue, and for each message there is inspect the kind of message (error, info, ...), use SetSelectionCharFormat appropriatly and then ReplaceSel.
Bookmarks