Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

RichEdit - Character-String Line Limit

Posted on 2006-06-17
10
Medium Priority
?
1,933 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

705 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