I try to add Strings to a Richedit component in a loop via
RichEdit1.Lines.Add(...) using Delphi 3.02.
Each time when 587 lines / 64452 bytes are already inserted the program
stops with an error message re. a problem with the insertion of a
RichEdit-line.
I can't believe this is an real limitation of RichEdit? By the way: the
procedure works fine when I replace the RichEdit-component by a simple
StringList.
Does anyone have an idea?
Regards,
Klaus M. Schulte
> I try to add Strings to a Richedit component in a loop via
> RichEdit1.Lines.Add(...) using Delphi 3.02.
>
> Each time when 587 lines / 64452 bytes are already inserted the program
> stops with an error message re. a problem with the insertion of a
> RichEdit-line.
>
> I can't believe this is an real limitation of RichEdit? By the way: the
> procedure works fine when I replace the RichEdit-component by a simple
> StringList.
Do something like: Editor.MaxLength := High (Integer) - 1024; Do NOT use 0
or High (Integer) itself.
Johannes.
The default maxLength property value of 0 yields a practical limit of 64K
for the control. Just set MaxLength to some suitably high value before
you start adding text to it.
Peter Below (TeamB) 10011...@compuserve.com)
No e-mail responses, please, unless explicitly requested!
Hi Johannes,
thanks for your tip. Unfortunately it does'nt work.
Below is a short code fragment of a test program I wrote. Even if
enlarge Maxlength, there is always the same result: the program stops
execution when data size becomes about 64kB. Do you have further ideas?
Regards, Klaus M. Schulte
--------------Program fragment starts here --------------------
procedure TForm1.Button1Click(Sender: TObject);
var
Lines,
LenTotal,
i : LongInt;
TempStr : String;
begin
Lines := 0;
RichEdit1.MaxLength := High (Integer) - 1024;
TempStr := '1234567890123456789012345678901234567890'
+'1234567890123456789012345678901234567890'
+'1234567890123456789012345678901234567890';
For i:=1 to 2000 do begin
RichEdit1.Lines.Add(TempStr);
LenTotal := LenTotal + length(TempStr);
Inc(Lines);
Caption := IntToStr(Lines)+'/'+IntToStr(LenTotal);
end;
end;
I have seen (but do not remember where) notes that implied that the
maximum text size cannot be changed when the RE control is not empty.
The VCL inserts text (at least a carriage return/linefeed) before your
code gets a shot at changing the text limit, so you might try clearing
the control prior to setting the maximum text length. (Others have
asserted that the empty control requirement is not true, so I can only
counter that it *may* be true for some versions of the RE control.)
You might also want to see http://home.att.net/~robertdunn/Yacs.html for
more information on RE controls. It is a C++ Builder site, but the VCL
is shared between BCB and Delphi and most of the solutions are actually
WinAPI calls which will work equally well for Delphi and BCB.
HTH.
robert
Klaus Martin Schulte wrote:
>
> Hi,
>
> I try to add Strings to a Richedit component in a loop via
> RichEdit1.Lines.Add(...) using Delphi 3.02.
>
> Each time when 587 lines / 64452 bytes are already inserted the program
> stops with an error message re. a problem with the insertion of a
> RichEdit-line.
>
> I can't believe this is an real limitation of RichEdit? By the way: the
> procedure works fine when I replace the RichEdit-component by a simple
> StringList.
>
Thanks, Robert. I added a RichEdit.Lines.Clear before filling the
component, unfortunately without success.
>
> You might also want to see http://home.att.net/~robertdunn/Yacs.html for
> more information on RE controls. It is a C++ Builder site, but the VCL
> is shared between BCB and Delphi and most of the solutions are actually
> WinAPI calls which will work equally well for Delphi and BCB.
I had a look to your site and found some useful hints.
Now, the following code sample I adapted from an article of your site
mostly works but leaves still one problem left:
For i:=1 to 1200 do begin
RichEdit1.SelLength := 0;
s := RichEdit1.SelStart;
try
RichEdit1.Lines.Add(TempStr);
except
On EOutOfResources do
if (RichEdit1.SelStart <> s + Length(TempStr) + 2)
then raise;
end;
end;
Now the Trx-Except-Block keeps the program running in spite of the error
message, but an empty line will appear in the RichEdit at the position
where the error occurs. This always happens when the amount of data
passes the 64kB-border.
Regards, Klaus M. Schulte
robert
I am using the Delphi 3 Standard VCL which contains RichEdit 2.0 as far
as I know.
But I took your hint re. RxLib and found out the following: using
RxRichEdit my test program doesn't report any errors, but the
RichEdit-content still shows a gap (means an empty row) at the former
place of error reporting. And this gap occurs only one time at a
datasize of 64kB. But not at 128kB and so on. Confusing.
BTW: The component(s) does a LoadFromFile or LoadFromStream without any
errors even with great amount of data.
It does not, TRichedit wraps version 1.0 of the rich edit common control
and still does in Delphi 5.
Peter,
why does the RTL-Source tell something about 'RichEdit20'-class (see
below)?
{*******************************************************}
{ }
{ Delphi Runtime Library }
{ Windows 32bit API Interface Unit }
{ }
{ Copyright (c) 1996,97 Borland International }
{ }
{*******************************************************}
unit RichEdit;
{$WEAKPACKAGEUNIT}
interface
uses Messages, Windows;
const
cchTextLimitDefault = 32767;
RICHEDIT_CLASSA = 'RichEdit20A'; { Richedit2.0 Window
Class. }
RICHEDIT_CLASSW = 'RichEdit20W'; { Richedit2.0 Window
Class. }
This is the API import unit that is the translation of richedit.h. It
declares all the richedit 2.0 stuff but that does not mean that Delphis
Trichedit class (declared in comctrls.pas) uses it. It does not. Look at
TCustomrichedit.CreateParams if you don't believe me <g>.
I think the problem is that the DLL implementing V 2.0 is not part of the
standard Win 95 installation, so is not guaranteed to be present on all
systems. And the DLL is not redistributable, as far as i know. If Borland had
decided to base TRichedit on V 2.0 apps using it would have problems on some
(probably now rather rare) older Win95 systems.
Regards, Klaus M. Schulte
As was pointed out elsewhere, RE 2.0 is not shipped with Delphi
(AFAIK). Certainly, the VCL does not use RE 2.0.
As for loading large amounts of text without problems with
LoadFromStream, this is the documented behavior. LoadFromStream is not
limited to the amount of text previously set with the EM_LIMITTEXT or
EM_EXLIMITTEXT (use the latter!). It only affects the amount of text
than can be typed by the user. If you load, say, a 100kb file, you may
find that you can only add text if you first delete text (and you can
add only as many characters as you delete).
If your system has riched20.dll in the \Windows\System or
(\Windows\System32 for NT?) directory or in the application directory,
then the RX Lib component should work. You might have to dig into it a
bit, though, because I *think* that RxRichEdit contains a flag to
specify which version of the DLL to load and it may load RE 1.0 if it is
not able to load RE 2.0. I could be wrong about that....
robert
Klaus Martin Schulte wrote:
>
> Robert,
>
> I am using the Delphi 3 Standard VCL which contains RichEdit 2.0 as far
> as I know.
>
Regards, Klaus M. Schulte
Robert Dunn wrote:
>...