The information in this article applies to:
SUMMARYThe GEDIT sample demonstrates how to create a CEdit derived class that uses a globally allocated memory segment instead of the application's local heap, thereby increasing the maximum contents of the edit control to the full 64K. MORE INFORMATIONGedit.exe http://www.microsoft.com/downloads/search.aspand then click How to use the Microsoft Download Center. GEDIT.ZIP can also be found in library 8 of the MSMFC forum as GEDITMP.ZIP Under Windows, edit controls use the application's local heap to store their text data. Unfortunately this can greatly limit their maximum capacity of 64K if the application uses a large portion of the local heap. In order to be able to utilize the entire 64K capability of the edit control it must have its own segment. Windows edit controls determine the local heap of the application by using the instance handle of the application. The instance handle of an application is just the data segment address (segment only). Therefore the edit control just uses the instance handle directly as the segment selector for its memory allocations. In order to get the edit control to have its own segment, PreCreateWindow must be overridden in a CEdit derived class. In this overridden member function GlobalAlloc is called to allocate a portion of memory from the global heap (the size is not important since the edit control will grow the segment as necessary). The handle returned from the GlobalAlloc is locked and the segment portion of the pointer is stored as the hInstance member of the CREATESTRUCT passed into the overridden PreCreateWindow. A LocalInit must also be called to set up the newly allocated memory as a heap. Once the hInstance variable contains the segment selector of this new segment the CEdit derived class will allocate memory from this segment instead of the application's local heap. Additional query words: kbinf 1gedit globedit
Keywords : kbfile kb16bitonly kbnokeyword kbMFC kbVC |
Last Reviewed: December 12, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |