Link to home
Start Free TrialLog in
Avatar of nmm
nmmFlag for Germany

asked on

long strings in TEDIT

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
ASKER CERTIFIED SOLUTION
Avatar of NickRepin
NickRepin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of NickRepin
NickRepin

To allow maximum text size use this:  TEdit->SendMessage(EM_LIMITTEXT,0,0);
Avatar of nmm

ASKER

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

ASKER

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().
Avatar of nmm

ASKER

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
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.
Avatar of nmm

ASKER

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)
Avatar of nmm

ASKER

Hi Nick again,
yes it uses DS :(
Do you know, how to persuade it to use globalmem?
nmm
 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. 
Avatar of nmm

ASKER

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...
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.