|
-
June 3rd, 2009, 11:00 PM
#10
Re: Apply formatting to Richedit control on the fly
 Originally Posted by ahmd
Thanks. Unfortunately in my case I can't limit my control with that. The specification for it to be multi-line and fully scrollable both horizontally and vertically. The size of the text is not limited to a small file either.
I tried browsing through the CodeGuru/Project articles and I couldn't find any that would provide this functionality for the RichEdit control. There were many that dealt with a user-created controls but not RichEdit. There are two that used it like that but I could clearly see in the comments section that those controls were too slow to process long text. I think I will try to code one myself and maybe post an article there if I succeed.
Regarding your suggestion about processing the EN_CHANGED message, how do you know which part of the text was actually changed?
You can certainly get clever with your algorithm; that's what programmers do. I've found that you can do a ****load of processing in the time between user keystrokes if you keep optimization in mind.
Scrolling isn't much of an issue. You can format everything at the start, then only worry about the stuff that needs to be changed dynamically in your EN_CHANGED handler. Even if you have to scan a few lines back or forward looking for tokens, this is still really fast compared to the time it takes a user to type a key.
As for what changes at EN_CHANGED, in my case, it doesn't matter. Only that something has changed is significant. Just format everything on the line that was changed. In your case, you may want to scan everything that is visible in the current viewport and reformat, or just look for tokens and change only things relevant between the tokens. If the change could affect stuff outside the viewport, maybe spawn or signal a thread to process in the background, but this may require synchronization and such between keystrokes and adds a lot of complexity when it may not be needed.
I really think you'll be surprised at how much you can get done in real-time in a decently constructed handler.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|