0

I am looking for a VCL control like TMemo that can manage multiple lines and do not have a 64kb data limit.
I have tried TRichEdit but encountered the RichEdit insert line error.
I do not need to insert rich text so a TMemo alike VCL control is enough.
Can anyone recommend one?

Johan
  • 74,508
  • 24
  • 191
  • 319
alancc
  • 487
  • 2
  • 24
  • 68
  • 1
    `TMemo` has no such limitation, and hasn't had since Win32 was introduced. If you're running into some limit below roughly 2GB, it's a problem somewhere in your app (or you're using Delphi 1 to produce 16-bit applications). – Ken White Oct 20 '13 at 22:19
  • @ken What's the default value of MaxLength on a new TMemo? – David Heffernan Oct 21 '13 at 04:16
  • @DavidHeffernan: 0, but that's immaterial. A "default value" doesn't make it a "limit". (Tested in Delphi 2007 w/File->New->VCL Forms->Application, drop a `THemo` on the blank form, and looking at `MaxLength` in the Object Inspector.) – Ken White Oct 21 '13 at 11:02
  • @Ken I was asking because I don't have a compiler to hand. I was under the impression that by default the control does limit text to 64k or so. But that limit can be increased. – David Heffernan Oct 21 '13 at 11:10
  • @David: The default value of a newly dropped TMemo.MaxLength is 0, and I use them all the time as text viewer type controls for history logs and so forth with much more than 64K text. The "limit" was based on Win16, and the last version of Delphi I recall being affected by it was D2 (where someone mistakenly hard-coded the limit into the VCL source, IIRC - it was removed in D3, again IIRC). – Ken White Oct 21 '13 at 11:16
  • Is it possible that XP's default limit is 64k. Certainly Win 9x is documented as not supporting more than 64k in an EDIT. But I'd discounted Win 9x. – David Heffernan Oct 21 '13 at 11:21
  • @David: WinXP's default is certainly not 64K, as I currently write apps that are used daily on a blend of WinXP (60%) and Win7 (40%), with the same apps running on both. I'd certainly have run into a "default limit" issue. (We just got rid of the last Win2K box about two years ago, and there was no such limit there either.) – Ken White Oct 21 '13 at 19:35

1 Answers1

4

You can use TMemo with more than 64K. Set the MaxLength property to increase the limit. The documentation says of this property:

Specifies the maximum number of characters the user can enter into the edit control.

Use MaxLength to limit the number of characters that can be entered into the edit control. A value of 0 indicates that there is no application-defined limit on the length.

Use MaxLength to limit the length of the text in an edit control if that text will be copied into a fixed-length buffer.

This property is implemented on top of the EM_SETLIMITTEXT message.

You could equally well use a TRichEdit control. The error that you observed does not indicate that the control is deficient. It merely indicates that your program contains an error.

Which control should you use? If you do not want formatting capabilities, use TMemo. Otherwise use TRichEdit.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490