Solved

long strings in TEDIT

Posted on 1997-04-28
12
283 Views
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.

Mircea
0
Comment
Question by:nmm
  • 6
  • 6
12 Comments
 
LVL 15

Accepted Solution

by:
NickRepin earned 50 total points
ID: 1396963
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
0
 
LVL 15

Expert Comment

by:NickRepin
ID: 1396964
To allow maximum text size use this:  TEdit->SendMessage(EM_LIMITTEXT,0,0);
0
 

Author Comment

by:nmm
ID: 1396965
Sorry, but this does *not* work. Dont know way....
0
 

Author Comment

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

0
 
LVL 15

Expert Comment

by:NickRepin
ID: 1396967
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().
0
 

Author Comment

by:nmm
ID: 1396968
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!!

Mircea
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 15

Expert Comment

by:NickRepin
ID: 1396969
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.
0
 

Author Comment

by:nmm
ID: 1396970
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)
0
 

Author Comment

by:nmm
ID: 1396971
Hi Nick again,
yes it uses DS :(
Do you know, how to persuade it to use globalmem?
nmm
0
 
LVL 15

Expert Comment

by:NickRepin
ID: 1396972
 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. 
0
 

Author Comment

by:nmm
ID: 1396973
OWL uses the procedure


function MakeObjectInstance(P: PWindowsObject): TFarProc;
const
  BlockCode: array[1..5] of Byte = (
    $5B,              { POP BX             }
    $2E, $C4, $1F,    { LES BX,CS:[BX]     }
    $EA);             { JMP FAR StdWndProc }
var
  Block: PInstanceBlock;
  Instance: PObjectInstance;
begin
  if InstFreeList = nil then
  begin
    Block := GlobalLock(GlobalAlloc(gmem_Fixed, SizeOf(TInstanceBlock)));
    Block^.Next := InstBlockList;
    Move(BlockCode, Block^.Code, 5);
    Block^.WndProcPtr := StdWndProcInstance;
    Instance := @Block^.Instances;
    repeat
      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);
  end;
  MakeObjectInstance := TFarProc(InstFreeList);
  PtrRec(Instance).Ofs := PtrRec(InstFreeList).Ofs;
  PtrRec(Instance).Seg := AllocCSToDSAlias(PtrRec(InstFreeList).Seg);
  InstFreeList := Instance^.Next;
  Instance^.ObjectPtr := P;
  FreeSelector(PtrRec(Instance).Seg);
end;

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...
0
 
LVL 15

Expert Comment

by:NickRepin
ID: 1396974
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.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now