Solved

Rich edit control: Fast Text Formatting

Posted on 1997-03-04
5
411 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
ID: 1298892
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
ID: 1298893
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
ID: 1298894
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
ID: 1298895

0
 

Accepted Solution

by:
Borka earned 200 total points
ID: 1298896

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

825 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