Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2024
  • Last Modified:

RichEdit - Character-String Line Limit

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
Wayne Barron
Asked:
Wayne Barron
1 Solution
 
Amir AzhdariCommented:
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
 
Wayne BarronAuthor Commented:
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
geobulCommented:
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
 
Wayne BarronAuthor Commented:
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
 
Wayne BarronAuthor Commented:
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
 
Wayne BarronAuthor Commented:
Any idea's on this one?
0
 
Wayne BarronAuthor Commented:
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
 
Russell LibbySoftware Engineer, Advisory Commented:

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
 
Wayne BarronAuthor Commented:
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Tackle projects and never again get stuck behind a technical roadblock.
Join Now