We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now


long strings in TEDIT

nmm asked
Medium Priority
Last Modified: 2013-12-04
I want to edit large files but TEdit from OWL(Pascal BP70, WIN3.11) does not want more than abaout 10 kB text.
What is wrong? I guess, that TEdit should
eat at least 64kB.

Watch Question

Use yourTEdit->SendMessage(EM_LIMITTEXT,<text_size>,0);Here is Article ID: Q89712 from MS knowledge base----------------------------------------------------------------------
The information in this article applies to:

 - Microsoft Win32 Software Development Kit (SDK)versions 3.1, 3.5,
   3.51, and 4.0

The default maximum size for a multiline edit (MLE) control in both Windows
and Windows NT is 30,000 characters. The EM_LIMITTEXT message allows an
application to increase this value. Setting "cchmax" to 0 is a portable
method of increasing this limit to the maximum in both Windows and Windows
NT. When cchmax is set to 0, the maximum size for an MLE is 4GB-1 (4
gigabytes minus 1).

Additional reference words: 3.10 3.50 3.51 4.00 95
KBCategory: kbprg
KBSubcategory: UsrCtl

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
To allow maximum text size use this:  TEdit->SendMessage(EM_LIMITTEXT,0,0);


Sorry, but this does *not* work. Dont know way....


It seems to me that WIN uses the local heap for my string in the TEdit. The local heap is limited to 3 kB.

Does TEdit control have ES_MULTILINE style?1.If you use dialog resource, check if it has DS_LOCALEDIT style.
This style specifies that edit controls in the dialog box will use memory in the application's data segment. By default, all edit controls in dialog boxes use memory outside the application's data segment.2.If dialog resource has DS_LOCALEDIT style, you can tryto retrieve a handle to the memory currently allocated for a  edit control (by sending EM_GETHANDLE message) and then reallocate this memory by using the LocalReAlloc().


Hm. It not from a dialogbox. It has ES_MULTILINE.
I insert the text from a file by several em_selreplace messages.
After inserting about 3 kB it will not longer insert.
Up to now I thought, it is a restriction of the edit-class itself. Please help again!!

1.What textLen parameters are you using in TEdit constructor (it must be zero)?2.It seems TEdit really uses local heap. You can evaluate following code for TEdit (in place where TEdit->GetHandle() is valid, ie !=0):uint16 editDS=FP_SEG(GlobalLock((HINSTANCE)TEdit->GetWindowWord(GWW_HINSTANCE)));if(editDS==_DS) {   // Your TEdit uses local heap!   // You should increase size of local heap :( .}   
At least, you can just reject my answer.


Ok, I will check, wether it uses Local heap.
May be you have an Idea, how to get it using global one???
p.s.: I will not reject your answer, the thing with cchmax
was new for me (at least)


Hi Nick again,
yes it uses DS :(
Do you know, how to persuade it to use globalmem?
 I am sorry, but cannot give you answer right now.  It seems if we create edit box as window by TEdit(TWindow* parent, int Id, const char far* text, int x, int y, int w, int h ...) it uses local heap. And this behavior is not property of TEdit but property of edit box itself.  I can only give you advice to use large model and to increase size of local heap.  I am using Win32. There are no such (and many other) problems in Win95/NT at all. I forgot Win 3.1 just like bad dream. 


OWL uses the procedure

function MakeObjectInstance(P: PWindowsObject): TFarProc;
  BlockCode: array[1..5] of Byte = (
    $5B,              { POP BX             }
    $2E, $C4, $1F,    { LES BX,CS:[BX]     }
    $EA);             { JMP FAR StdWndProc }
  Block: PInstanceBlock;
  Instance: PObjectInstance;
  if InstFreeList = nil then
    Block := GlobalLock(GlobalAlloc(gmem_Fixed, SizeOf(TInstanceBlock)));
    Block^.Next := InstBlockList;
    Move(BlockCode, Block^.Code, 5);
    Block^.WndProcPtr := StdWndProcInstance;
    Instance := @Block^.Instances;
      Instance^.Code := $E8;  { CALL NEAR PTR Offset }
      Instance^.Offset := (2 - 3) - PtrRec(Instance).Ofs;
      Instance^.Next := InstFreeList;
      InstFreeList := Instance;
      Inc(PtrRec(Instance).Ofs, SizeOf(TObjectInstance));
    until PtrRec(Instance).Ofs = SizeOf(TInstanceBlock);
    InstBlockList := PtrRec(Block).Seg;
    ChangeSelector(PtrRec(Block).Seg, PtrRec(Block).Seg);
  MakeObjectInstance := TFarProc(InstFreeList);
  PtrRec(Instance).Ofs := PtrRec(InstFreeList).Ofs;
  PtrRec(Instance).Seg := AllocCSToDSAlias(PtrRec(InstFreeList).Seg);
  InstFreeList := Instance^.Next;
  Instance^.ObjectPtr := P;

for any Window

What do you think: is the DS-use due to this alloccstodsalias?

I can up to now not switch to Win32, unfortunately...
I think that in any case OWL uses CreateWindow() to create edit box.  Edit box created by CreateWindow() uses local heap (as we checked). Next, OWL does not change (and cannot according WinAPI docs) memory usage for edit box window. So OWL is not the source of problem. May be I am wrong.You can try to create edit box via CreateWindow() and do not use TEdit object.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.