Solved

RichEdit - Character-String Line Limit

Posted on 2006-06-17
10
1,741 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 6

Expert Comment

by:Amir Azhdari
ID: 16928384
0
 
LVL 30

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
Gigs: Get Your Project Delivered by an Expert

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

 
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 30

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 30

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 30

Author Comment

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

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

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi cmd execution 6 60
Using idhttp to login to instagram 2 89
Print Graphic and Text to Epson TM-T88v 12 247
Multiple image collision 13 74
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

785 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