Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SetWindowText has a 32KB limit?

Status
Not open for further replies.

sparafucile17

Programmer
Apr 5, 2002
40
0
0
US
I am using setWindowText to add text to an Edit box, and everything's just peachy. That is until I really start to fill it up with a lot of text. I am using the edit box for a log, so I am going to always have a lot of data in it. On average I think I will fill it to about 45KB.

The problem is that I have noticed that after 32KB worth of data in the edit box, the edit box does not continue to draw text:

Text Size
---- ----
Hello 32755
Hello 32760
Hello 32765
Hel 32768

And any future setWindowTexts will not add the text to the screen (at least not that I can visibly see) My question is this, is there any way to increase this limit?

I know that I can clear the edit box when it gets close to this limit (say about 100 bytes before) and I have already tested that this works. But since my application is a "LOG" typically around 45KB it's kinda a pain to clear all the old data. Not to mention that I could be losing potentionally important data!

Can anyone help?

Jeff Tackett
Software Engineer
Visteon Corp.
 
Haven't had a chance to test this in C/C++, but it works fine in VB:
SendMessage(hwndOfEditBox, WM_SETTEXT, NULL, string), where "string" is the text you wish to fill the edit box with.

rgds
Andy
 
RichEditBox has no such limits, I use it with files over 5 MB.
 
Here is a part of the MSDN library:

When the system creates an edit control, it automatically creates a text buffer, sets its initial size, and increases the size as necessary. The size can be up to a predefined limit of approximately 32 KB for single-line edit controls. Because this limit can change, it is called a soft limit. An application can set a hard limit to the buffer size by sending an EM_SETLIMITTEXT message to the edit control. If the buffer exceeds either limit, the system sends the application an EN_ERRSPACE message. An application can retrieve the current text limit by sending an EM_GETLIMITTEXT message.

<End MSDN library>
 
Ok, I think that I'm going to switch over to a RichEdit instead of just an edit box. But, of course I have another problem when trying to do this... When I put a rich edit in my Dialog, it won't let me run the program anymore!

What happens is that now (with the RichEdit) when I run the exe or debug, the program exits with code 0. Nothing gets displayed, no windows or anything. I guess this reminds me that I should mention that edit box is in the Main Dialog that is first launched by the main thread. If I delete the RichEdit Box and re-compile the program executes normally.

I have never used RichEdits before, is there any special setup that I should consider?

Thanks for the help so far!
Jeff
 
RichEdit is not initialized, if You use only dialog with RichEditBox. You should call AfxInitRichEdit() before create dialog or try to load Riched32.dll. See Q166132, Q316375 and Q181664 on search.microsoft.com for more info.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top