INFO: Limits on Text in CEditView and CEdit

Last reviewed: March 2, 1998
Article ID: Q181932
The information in this article applies to:
  • Microsoft Visual C++, 32-bit Editions, versions 4.0, 4.0a, 4.1, 4.2, 4.2b, 5.0

SUMMARY

The CEditView and the CEdit classes wrap the Windows edit control. These classes have limits on the amount of text that they can contain. These limits are operating-system dependent.

Windows 95 has a 64 KB limit on edit controls that cannot be increased. To adjust the limit within this range, use CEdit::SetLimitText(UINT nMax), where nMax is the number of bytes in the new text limit. You can set nMax to 65535 to obtain the maximum (which is actually 64000 bytes).

Windows NT has a practical, machine-dependent limit on edit controls. Users will run into this machine-dependent limit before they reach operating- system dependent limit. You can increase the limit by using SetLimitText(UINT nMax). You can set nMax to some large number such as 4111222333 to obtain the maximum your machine will allow. The practical limit is based on the computer's RAM. For example, it is possible to load 1 million very short lines of text (nearly 8 MB) into an edit control using a computer with 64 MB of RAM. Unfortunately, it may use up nearly 100 percent of the CPU power and take several minutes to load. Once it is loaded in memory, the control works slowly.

If you need to use a control that is expected to contain near or over 64 KB of data, use CRichEditCtrl or CRichEditView. These classes wrap the rich edit Windows control. In both Windows 95 and Windows NT4, there is no definite limit on the amount of text that the control can hold. Theoretically, the rich edit control allows for a maximum of 4 GB of text. In practice, you can run into performance problems with even less than 1 MB of text. Files with many lines of text (not necessarily large files, because the lines can be very short) require a lot of time and CPU power to process the first time scrolling or resizing of the view window. Once the CPU has processed these actions, the control behaves normally.

The maximum text that a CRichEditCtrl can hold can be changed by calling CRichEditCtrl::LimitText(). However, this will not effect any of the problems just mentioned. One possible option for storing huge amounts of text into a RichEdit control would be to only stream in the amount of text that is needed at a time. This would not be easy, because you need to handle the scrolling logic to load in the appropriate text for the position of the scrollbar thumb for this method to work.

Another option is to design your own Cview-based class.

MORE INFORMATION

Some word processing sample programs that ship with Visual C++ are:

  • MultiPad: Provides a simple illustration of how to use CEditView.
  • SuperPad: Illustrates advanced uses of CEditView through class derivation, including toggling the word wrap state of the edit control and changing the screen and printer font.
  • WordPad: Example of a professional word processing application written using MFC that is included with Windows 95. It is based on the CRichEditView, CRichEditDoc, and CRichEditCntrItem classes.

REFERENCES

For additional information, please see the following articles in the Microsoft Knowledge Base:

   ARTICLE-ID: Q166132
   TITLE     : PRB: Dialog With RichEdit May Fail During Creation

   ARTICLE-ID: Q166213
   TITLE     : BUG: Right-Clicking CRichEditView Doesn't Activate Frame

   ARTICLE-ID: Q117778
   TITLE     : HOWTO: Change the Background Color of an MFC Edit Control

   ARTICLE-ID: Q155224
   TITLE     : PRB: Using CEdit SetModify/GetModify Returns Invalid Values

For additional information about writing 16-bit applications, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q118308
   TITLE     : SAMPLE: CEdit Derived Class That Uses the Global Heap

(c) Microsoft Corporation 1998, All Rights Reserved. Contributions by Philip Spory, Microsoft Corporation


Additional query words: CEdit CEditView CRichEditCtrl CRichEditView limit
maximum max rich richedit edit control
Version : WINNT:4.0,4.0a,4.1,4.2,4.2b,5.0
Platform : winnt
Issue type : kbinfo


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: March 2, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.