Discussion:
CEdit SetWindowText rediculously slow
(too old to reply)
Rob
2008-03-18 11:51:02 UTC
Permalink
Hi,
I have an MFC application, runing on XP.
When I do SetWindowText() on an EditControl, it takes >950 ms
This seems rediculous, even when reallocation takes place.

What can cause this.
Is there a faster way to update the text ?

Greetings,
Rob.
Scott McPhillips [MVP]
2008-03-18 13:49:08 UTC
Permalink
Post by Rob
Hi,
I have an MFC application, runing on XP.
When I do SetWindowText() on an EditControl, it takes >950 ms
This seems rediculous, even when reallocation takes place.
What can cause this.
Is there a faster way to update the text ?
Are you perhaps replacing a massive amount of text just to append something
to the end? If so, there is a non-obvious way to append text to the
control:

m_edit.SetSel(-1,-1);
m_edit.ReplaceSel(strTemp);

If you are using the edit control to append line-by-line you will find it
much better to use a list box control instead.
--
Scott McPhillips [VC++ MVP]
Joseph M. Newcomer
2008-03-23 23:34:13 UTC
Permalink
Well, this question as posed is unanswerable. Reason: you told us NOTHING of value here.

First, how big is your text block? Numbers matter here!

Second, how did you come up with the number 950ms? Without knowing how this number was
derived, there is no way to tell what it means.

Third, what are you trying to accompish? For example, it is a common design error to use
an edit control as a way of recording text coming from a pipe, or from the equivalent of a
debug-print statement. This is almost always a mistake. Use a simple listbox, and it is
much faster. Not only that, but it is less prone to annoying flicker, to nasty side
effects if you are trying to read something while new material is being added, and other
issues. I discovered this around 1991, and over the next few years developed the
technology which is on my Web site as the Logging ListBox control.

So you have not stated your goals, have not said what the magnitude of the problem is, and
have not stated how you derived the numbers, so how is it we are supposed to give a
meaningful answer?
joe
Post by Rob
Hi,
I have an MFC application, runing on XP.
When I do SetWindowText() on an EditControl, it takes >950 ms
This seems rediculous, even when reallocation takes place.
What can cause this.
Is there a faster way to update the text ?
Greetings,
Rob.
Joseph M. Newcomer [MVP]
email: ***@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm

Loading...