Solved

long strings in TEDIT

Posted on 1997-04-28
12
286 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

808 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