Solved

Rich edit control: Fast Text Formatting

Posted on 1997-03-04
5
402 Views
Last Modified: 2013-12-03
I would like to display colured text inside of rich edit control. The text is not in RTF, so I have to set the color later using the EM_SETCHARFORMAT message.

Unfortunately this is very slow. Every time the message is sent RTF control rewraps and redraws.  It takes many seconds to load some 10 kilobytes of text.

Is there a faster way of setting the CharFormatting and show changes later when formatting is finished?
0
Comment
Question by:tomaz012197
5 Comments
 
LVL 1

Expert Comment

by:gvg
Comment Utility
How about hiding the text with EM_HIDESELECTION then
format the text and then unhide it.  
There probably is a better way to do this.
0
 

Author Comment

by:tomaz012197
Comment Utility
I did the EM_HIDESELECTION, but this only hides the selection. The entire control is still rewrapped every time the EM_SETCHARFORMAT is sent.

The WM_SETREDRAW didn't help either!

0
 
LVL 23

Expert Comment

by:chensu
Comment Utility
I don't think there is a faster way because that is done internally. Since a rich edit control is a window, you can use ShowWindow() to hide it before the EM_SETCHARFORMAT is sent and show it after.

0
 

Author Comment

by:tomaz012197
Comment Utility

0
 

Accepted Solution

by:
Borka earned 200 total points
Comment Utility

Well, there's a message, called WM_SETREDRAW.
You can:

// Assuming SetRedraw is a func. which sends WM_SETREDRAW
SetRedraw(hWnd, FALSE);
reformat your text and
SetRedraw(hWnd, TRUE);
UpdateWindow(hWnd);

Still, MsWord will probably do a job faster, but this
is the fastest solution available when using RichEdit.

Hav a nice day,
  Borka.

0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now