Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does TEdit only shows text with length equals or less than 37440 characters?

If you do this:

  Edit1.Text := StringOfChar('X', 37440);

It will show the text, however if you do this:

  Edit1.Text := StringOfChar('X', 37441);

The text will not appear.

Does anybody knows why?
If this is an error, there is another way of adjusting rather than replacing all existing components to TMemo?
Why 37440 Anyway?

like image 756
EProgrammerNotFound Avatar asked Oct 03 '22 15:10

EProgrammerNotFound


1 Answers

On the face of it you ought to be able to control this using the EM_LIMITTEXT message:

The EM_LIMITTEXT message limits only the text the user can enter. It does not affect any text already in the edit control when the message is sent, nor does it affect the length of the text copied to the edit control by the WM_SETTEXT message. If an application uses the WM_SETTEXT message to place more text into an edit control than is specified in the EM_LIMITTEXT message, the user can edit the entire contents of the edit control.

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.

And this message is exposed by the MaxLength property of TEdit.

However, setting MaxLength to a large value doesn't appear to help. I cannot persuade a single line edit control to display a large number of characters.

I suspect the only viable option for you is to use a multi-line edit control, that is a TMemo.

I'm sure MS would argue that single line edit controls are not designed to hold thousands of characters and so they have no motivation to make that control more capable.

FWIW, with the Unicode version of the control, the cutoff appears to be at 37444 rather than 37440!

like image 161
David Heffernan Avatar answered Oct 18 '22 05:10

David Heffernan