Recent

Author Topic: TRichMemo, how to increase line limit of 500?  (Read 4017 times)

Trenatos

  • Hero Member
  • *****
  • Posts: 508
  • Software developer - Open source contributor
    • MarcusFernstrom.com
TRichMemo, how to increase line limit of 500?
« on: August 27, 2015, 05:31:02 pm »
I'm using TRichMemo, and programmatically adding a lot of text from a process.

But it seems that the control is limited to 500 lines of text.

I'm creating the controls programmatically as well, and it all works well except for the line limit.

I've tried maxlength, but no success.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2290
    • havefunsoft.com
Re: TRichMemo, how to increase line limit of 500?
« Reply #1 on: August 27, 2015, 06:10:25 pm »
could you please provide the sample code?
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

Trenatos

  • Hero Member
  • *****
  • Posts: 508
  • Software developer - Open source contributor
    • MarcusFernstrom.com
Re: TRichMemo, how to increase line limit of 500?
« Reply #2 on: August 27, 2015, 07:44:42 pm »
Here's the piece of code that dynamically creates the richedit controls.

Except for the line limit, it works great

Code: [Select]
for i := 1 to 50 do
  begin
    REdit := TRichMemo.Create(Self);
    REdit.Parent := Self;
    REdit.Name:= 'RichMemo'+ intToStr(i);

    REdit.AnchorToNeighbour(akLeft, 0, serverList);
    REdit.AnchorToNeighbour(akTop, 10, startServerButton);
    REdit.AnchorToNeighbour(akBottom, 0, Form1);
    REdit.AnchorToNeighbour(akRight, 0, Form1);
    REdit.AnchorSide[akBottom].Side:=asrBottom;
    REdit.AnchorSide[akBottom].Control:=Form1;
    REdit.AnchorSide[akRight].Side:=asrRight;
    REdit.AnchorSide[akRight].Control:=Form1;
    REdit.text := '';

    // Settings/options
    REdit.ReadOnly    := true;
    REdit.ScrollBars  := ssAutoBoth;
    REdit.WordWrap    := false;
    REdit.MaxLength   := 0;

    REdit.visible     := false;
  end;

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3653
  • I like bugs.
Re: TRichMemo, how to increase line limit of 500?
« Reply #3 on: August 27, 2015, 07:54:55 pm »
Quote
  REdit.visible     := false;

Why would you create 50 hidden RichMemos?

Trenatos

  • Hero Member
  • *****
  • Posts: 508
  • Software developer - Open source contributor
    • MarcusFernstrom.com
Re: TRichMemo, how to increase line limit of 500?
« Reply #4 on: August 27, 2015, 08:02:49 pm »
There are better ways to do it, but that's a nice simple bruteforce way to have access to 50 TRichMemos with separate known identifiers.

I'm writing a piece of software used for handling multiple servers, each server run as a process and its output piped into a separate richmemo.

This way it can handle up to 50 separate server instances.

I plan on making it properly dynamic, so there's no hardcoding a limit, but I needed a quick solution.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2290
    • havefunsoft.com
Re: TRichMemo, how to increase line limit of 500?
« Reply #5 on: August 27, 2015, 09:38:50 pm »
ok, so how do you know you reach the limit of 500 lines?
The code sample above doesn't demonstrate the problem.

For example, if I add the following code to the sample you've shown:
Code: [Select]
  REdit:=TRichMemo(Self.FindComponent('RichMemo1'));
  for i:=0 to 1000 do
    REdit.Lines.Add('line #'+IntToStr(i));
  REdit.visible:=true;
as the result I'm seeing RichMemo with 1001 lines in place.
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

Trenatos

  • Hero Member
  • *****
  • Posts: 508
  • Software developer - Open source contributor
    • MarcusFernstrom.com
Re: TRichMemo, how to increase line limit of 500?
« Reply #6 on: August 27, 2015, 09:46:43 pm »
As the output from the process keeps adding lines, it quickly goes over 500.

When it hits 500, lines are added and lines are removed.

I know the number because I copied the output and checked it with a line counter online.

Trenatos

  • Hero Member
  • *****
  • Posts: 508
  • Software developer - Open source contributor
    • MarcusFernstrom.com
Re: TRichMemo, how to increase line limit of 500?
« Reply #7 on: August 27, 2015, 09:52:49 pm »
AHA!

I found the issue.

Another coder helped me with some of the other code in this program, and he put in a hardcoded limit of 500, I didn't notice it until now.

Problem appears to be solved, and I've learned to vet code more closely     :)