Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

RichEdit - Character-String Line Limit

Posted on 2006-06-17
10
Medium Priority
?
1,988 Views
Last Modified: 2013-11-22
Hello All;

  Can someone tell me how to overcome the RichEdit Line limit?
(Wordpad has about a 3,068 character Line Limit. I need to get way over this line limit, about 10,000+ Characters
Is what I need to go with)

I know how to overcome the File Size limit.
But what I am needing is the [Line - String] Limit.

Any idea's on this one?

Thanks all;
Carrzkiss
0
Comment
Question by:Wayne Barron
10 Comments
 
LVL 6

Expert Comment

by:Amir Azhdari
ID: 16928365
add this line to the form's create :

procedure TForm1.FormCreate(Sender: TObject);
begin
  sendmessage(RichEdit1.Handle,EM_LIMITTEXT,0,$7FFFFFFF);
end;

Regards
Azhdari
0
 
LVL 31

Author Comment

by:Wayne Barron
ID: 16928484
Thought I was already using that, but did not add it into the newest version of the code.
Except, I am using
RichEdit1.Perform(EM_LIMITTEXT,0,$3FFFFFFF); // 64mb file size

What does the                                $7FFFFFF);  // ??mb file Size ??

Size limit for 1-line is: 4099 Characters.

The code that you provided, as well is what I am using, allows to load more "Lines"
I need to add in more "Characters"
It seems that this might be a limitation in the RichEdit control?

Also, I checked out the links, "Thanks for them"
I am not experiancing any problems thus far, And the biggest file size that I have loaded is:
Size: 16.6mb
Lines: 22,921
Char-Count: 17506692
memory: 4,684
CPU: Peaks: 99% for 1-second then settles at: 00% --> Steady

I use this for the Memory, to hold it steady through out all.
SetProcessWorkingSetSize(GetCurrentProcess, $FFFFFFFF, $FFFFFFFF);

Anyway.
If anybody knows how to add more then the 4,099 Character Per Line Limit, I would love to know.

Thanks All, and Thanks [Azhdari]
Carrzkiss
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 17

Expert Comment

by:geobul
ID: 16935555
Hi,

What is your OS version? You shouldn't experience such line-length or size problems in 2000/XP or more, I think. I've just loaded 50 MB file in a richedit using Delphi 5 on XP without any EM_LIMITTEXT settings.

Regards, Geo
0
 
LVL 31

Author Comment

by:Wayne Barron
ID: 16936006
win2k pro sp4 rollup

I do not think that everybody is understanding what I am referring too.

To recreate this issue, do the following.


Add the following line (1 single line, just copy/paste the line over and over again, and it will do a return
And create another line at around 4,000+ character length)

ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss

(Just copy the sssss from above, and start pasting it into 1-LINE (Not line after line) 1-Line)
I need for the "Single Line" to continue on and paste 10,000 characters.

You will see what I am referring too.

I can load 50+mb files with no problem as well.
0
 
LVL 31

Author Comment

by:Wayne Barron
ID: 16938389
I was given this information but I do not know how to convert code over from C to Delphi
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/editcontrols/editcontrolreference/editcontrolmessages/em_getline.asp

lResult = SendMessage(      // returns LRESULT in lResult    
 (HWND) hWndControl,      // handle to destination control    
 (UINT) EM_GETLINE,      // message ID    
(WPARAM) wParam,      // = (WPARAM) () wParam;    
(LPARAM) lParam      // = (LPARAM) (LPCTSTR) lParam; );

Any idea's?
0
 
LVL 31

Author Comment

by:Wayne Barron
ID: 16958599
Any idea's on this one?
0
 
LVL 31

Author Comment

by:Wayne Barron
ID: 16968956
I was just given this information, maybe someone can assist in this? Please

=============================
 lParam
        Pointer to the buffer that receives a copy of the line. Before
sending the message, set the first word of this buffer to the size, in
TCHARs, of the buffer. For ANSI text, this is the number of bytes; for
Unicode text, this is the number of characters. The size in the first word
is overwritten by the copied line.

Simply specify a buffer that is large enough, and EM_GETLINE will fill it as
much as it can.  You can use EM_LINELENGTH to find out the length of a line
beforehand so that you can allocate a large enough buffer as needed.
=============================
0
 
LVL 26

Accepted Solution

by:
Russell Libby earned 2000 total points
ID: 16975672

The work break procedure for the rich edit seems to be the key. The example below will show you how to break the limit set by the default wordbreak proc (only needs to be set once), and then shows adding very long lines and how to read them back.
Let me know if there are question/problems

Regards,
Russell

---

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ComCtrls;

type
  TForm1 = class(TForm)
    RichEdit1: TRichEdit;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1:      TForm1;

implementation
{$R *.DFM}

const
  WB_CLASS_WHITESPACE  =  0;
  WB_CLASS_LINEBREAK   =  1;
  WB_CLASS_DELIMITER   =  2;
  WB_CLASS_NORMALCHAR  =  3;

const
  WB_CLASSIFY          =  3;
  WB_MOVEWORDLEFT      =  4;
  WB_MOVEWORDRIGHT     =  5;
  WB_LEFTBREAK         =  6;
  WB_RIGHTBREAK        =  7;

const
  WBF_CLASS            = $0000000F;
  WBF_ISWHITE          = $00000010;
  WBF_BREAKLINE        = $00000020;
  WBF_BREAKAFTER       = $00000040;

const
  WHITESPACE:          Set of Char = [#9, #32];
  DELIMITERS:          Set of Char = ['"', '[', ']', '(', ')', ';', ',', '.', '\', ''''];
  LINEBREAKERS:        Set of Char = [#10, #13];

function IsInDelimiterList(C: Char): Boolean;
begin

  // Check for char in delimiter type list
  result:=(C in LINEBREAKERS);

end;

function EditWordBreakProcEx(pchText: PChar; ichCurrent: Integer; cch: Integer; Code: Integer): Integer; stdcall;
var  i:             Integer;
     found:         Boolean;
     initial_pos:   Integer;
begin

  result:=0;

  case Code of
     WB_LEFT           :
     begin
        while (not(IsInDelimiterList(pchText[ichCurrent])) and (ichCurrent > 0)) do Dec(ichCurrent);
        if (ichCurrent > 0) then
           result:=Succ(ichCurrent)
        else
           result:=-1;
     end;
     WB_RIGHT          :
     begin
        while (not(IsInDelimiterList(pchText[ichCurrent])) and (ichCurrent < cch)) do Inc(ichCurrent);
        if (ichCurrent > 0) then
           result:=ichCurrent
        else
           result:=-1;
     end;
     WB_ISDELIMITER    :
     begin
        result:=1
     end;
     WB_CLASSIFY       :
     begin
        if (pchText^ in WHITESPACE) then
           result:=WBF_ISWHITE or WB_CLASS_WHITESPACE
        else if (pchText^ in DELIMITERS) then
           result:=WBF_BREAKAFTER or WB_CLASS_DELIMITER
        else if (pchText^ in LINEBREAKERS) then
           result:=WBF_BREAKLINE or WB_CLASS_DELIMITER
        else
           result:=WB_CLASS_NORMALCHAR;
     end;
     WB_MOVEWORDLEFT   :
     begin
        Dec(ichCurrent);
        found:=False;
        while IsInDelimiterList(pchText[ichCurrent]) do Dec(ichCurrent);
        while (ichCurrent < cch) and not(found) and (ichCurrent >= 0) do
        begin
           found:=IsInDelimiterList(pchText[ichCurrent]);
           if (found and (ichCurrent >=0)) then
              result:=Succ(ichCurrent)
           else
           begin
              result:=MaxInt;
              Dec(ichCurrent);
           end;
         end;
     end;
     WB_MOVEWORDRIGHT  :
     begin
        if not(IsInDelimiterList(pchText[ichCurrent])) then
        begin
           while (not(IsInDelimiterList(pchText[ichCurrent])) and (ichCurrent < cch)) do Inc(ichCurrent);
        end;
        while (IsInDelimiterList(pchText[ichCurrent]) and (ichCurrent < cch)) do Inc(ichCurrent);
        if (ichCurrent < cch) then
           result:=Succ(ichCurrent)
        else
           result:=-1;
     end;
     WB_LEFTBREAK      :
     begin
        while (not(IsInDelimiterList(pchText[ichCurrent])) and (ichCurrent > 0)) do Dec(ichCurrent);
        if (ichCurrent > 0) then
           result:=ichCurrent
        else
           result:=-1;
     end;
     WB_RIGHTBREAK     :
     begin
        while (not(isInDelimiterList(pchText[ichCurrent])) and (ichCurrent < cch)) do Inc(ichCurrent);
        if (ichCurrent > 0) then
           result:=ichCurrent
        else
           result:=-1;
     end;
  end;

end;

function RichEditGetLine(Handle: HWND; Index: Integer): string;
var  Text: array [0..32768] of Char;
     L: Integer;
begin

  Word((@Text)^) := SizeOf(Text);
  L := SendMessage(Handle, EM_GETLINE, Index, Longint(@Text));
  if (Text[L - 2] = #13) and (Text[L - 1] = #10) then Dec(L, 2);
  SetString(Result, Text, L);

end;

procedure TForm1.Button1Click(Sender: TObject);
var  s:       String;
begin

  // Remove text limit from control
  RichEdit1.Perform(EM_LIMITTEXT, 0, $7FFFFFFF);

  // Set custom word break procedure
  RichEdit1.Perform(EM_SETWORDBREAKPROC, 0, Integer(@EditWordBreakProcEx));

  // Example of adding a really long line
  RichEdit1.Lines.Add(StringOfChar('X', 16 * 1024));

  // Get the first line, line 0. We can't use RichEdit.Lines[0] because the internal
  // buffer used is limited to 4KB.
  s:=RichEditGetLine(RichEdit1.Handle, 0);

  // Show line length
  ShowMessage(IntToStr(Length(s)));

end;

end.
0
 
LVL 31

Author Comment

by:Wayne Barron
ID: 16975855
You are the man Russell;

Love it.
Now, no more Character LineLimit Restrictions.

Thank you so very much.

Wayne

Uped the Points from 125 -to- 500.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

971 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