Size Limits for a Multiline Edit Control

Last reviewed: July 22, 1997
Article ID: Q74225
3.00 3.10 WINDOWS kbprg

The information in this article applies to:

  • Microsoft Windows Software Development Kit (SDK) for Windows versions 3.1 and 3.0

SUMMARY

In the Microsoft Windows graphical environment, the amount of text that a user can enter into a multiline edit control is limited by the number of characters the user can type into the edit control (set using the EM_LIMITTEXT message) and by the size of the buffer the edit control uses to hold the text.

In general, Windows edit controls were designed as vehicles into which the user can enter and edit small amounts of text. They cannot be used as large-scale text editors.

MORE INFORMATION

Initially, the user can enter a maximum of 30,000 bytes into a multiline edit control. If the user attempts to enter more text, the edit control beeps and does not accept the characters. An application can set this limit to any value between 1 and 65,535 (0xFFFF) characters by sending the edit control an EM_LIMITTEXT message.

A multiline edit control is also subject to the following limitations:

  1. The maximum number of characters in a single line is 1024.

  2. The maximum width of a line is 30,000 pixels.

  3. The maximum number of lines is approximately 16,350.

By default, the edit control's text buffer is allocated from the application's local heap. Windows can dynamically grow and shrink the text buffer as the user enters text into and deletes text from the edit control. The amount of text that can be edited is determined by how large a buffer Windows can allocate from the local heap. Because the heap shares the application's default data segment with many other objects, the maximum size of the text buffer is likely to be substantially smaller than 64K.

An application can specify a global text buffer for an edit control. By using a global buffer, an edit control can store almost 64K of data. The actual size limit of an edit control depends on the number of lines stored in the edit control. Edit controls contain a dynamically allocated buffer, which contains offsets into the text buffer for each line. Because each line requires 2 bytes of storage, the buffer grows as the number of lines in the edit control grows. In addition to the buffer, there are slightly less than 100 bytes of fixed overhead associated with an edit control. Windows does not provide any built-in method to process a single block of more than 64K of text.

One major drawback of using a global memory buffer is that the EM_GETHANDLE and EM_SETHANDLE messages cannot be used to change the memory used by the edit control.

For more information on using a global memory buffer, query the Microsoft Knowledge Base on the following words:

   prod(winsdk) and GLBEDIT

Editing features such as Cut and Paste do not affect the amount of text that can be edited because Windows uses global memory to implement these features.


Additional reference words: 3.00 3.10
KBCategory: kbprg
KBSubcategory: UsrCtl
Keywords : kb16bitonly


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 22, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.