PookyFan
PookyFan

Reputation: 840

Winapi: edit control not expanding its buffer

According to MSDN:

When the system creates an edit control, it automatically creates a text buffer, sets its initial size, and increases the size as necessary.

Yeah, only it doesn't. I have an edit control in my app that shows various logs, and I keep adding text to it using EM_SETSEL message (to find the end of the text in control's buffer) and EM_REPLACESEL message (to append some text to it). I don't know if it's a best way, but it's been working well so far. Today, however, I found out that if I try to append some text when there are lots of logs in edit control already, my app fails to do so. Maximum lenght of text that's shown in it is equal to 30k characters and when I try to append any more logs, it just fails, nothing happens. At first I set it as read-ony edit control, but nothing changes if I make it editable. Just when I try to type more than 30k characters in it, it acts as if I wasn't typing anything.

And now: I know that you can handle buffer expanding by yourself, but that's not the case here. If it is written that it should be expanded automatically, why doesn't it occur? Maybe I accidentaly set something that stops the application from increasing the buffer's size? I don't know and I can't find any answer to that, so I was just wondering if there's any way to actually make my application to expand that buffer on its own.

Upvotes: 1

Views: 617

Answers (1)

Jonathan Potter
Jonathan Potter

Reputation: 37122

You need to set a text limit with the EM_LIMITTEXT message. Otherwise:

Before EM_LIMITTEXT is called, the default limit for the amount of text a user can enter in an edit control is 32,767 characters.

Upvotes: 3

Related Questions