Recent

Author Topic: [SOLVED] TMemo to hold more than 4k lines  (Read 2306 times)

alveselvis2

  • New Member
  • *
  • Posts: 10
[SOLVED] TMemo to hold more than 4k lines
« on: July 23, 2018, 07:15:48 pm »
Hi everyone,
Is there any componente or any workaround to make a TMemo in Lazarus handle files with more than 4k lines?
I'm trying to load a file with 5k lines in it (it's not much text, it's just that each sentence is in a different line). It loads correctly, but any action towards the Memo (even turning wordwrap to false) returns the error "Failed to create Win32 Control, error 0: The operation was successfully completed" and then the program asks to abort and close.

Already tried in a Win32 and a Win64 version of the program, not tried on Linux yet
I appreciate any help, thank you.
« Last Edit: July 23, 2018, 09:59:19 pm by alveselvis2 »

Handoko

  • Hero Member
  • *****
  • Posts: 5131
  • My goal: build my own game engine using Lazarus
Re: TMemo to hold more than 4k lines
« Reply #1 on: July 23, 2018, 07:32:53 pm »
Have to try TSynEdit?
http://wiki.lazarus.freepascal.org/SynEdit

I wrote a small note taking program using TMemo. Later I replaced it with TSynEdit. It's not hard, just some little adaptations.

alveselvis2

  • New Member
  • *
  • Posts: 10
Re: TMemo to hold more than 4k lines
« Reply #2 on: July 23, 2018, 07:44:37 pm »
It's possible a synedit will work, but it's too different from a TMEMO (not having wordwrap property and only accepting monospaced fonts suck)

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: TMemo to hold more than 4k lines
« Reply #3 on: July 23, 2018, 07:45:39 pm »
There is no problem loading 5K lines into TMemo.
« Last Edit: July 23, 2018, 07:48:24 pm by engkin »

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: TMemo to hold more than 4k lines
« Reply #4 on: July 23, 2018, 07:51:37 pm »
The error message is "Failed to create Win32 Control". Why do you assume it has anything to do with loading text?

alveselvis2

  • New Member
  • *
  • Posts: 10
Re: TMemo to hold more than 4k lines
« Reply #5 on: July 23, 2018, 08:38:17 pm »
Indeed, it perfectly loads the 5k lines, the problem is doing changes to this text.
For example, I added a button in your test program to turn Memo1.WordWrap := not Memo1.WordWrap and the same error showed up...


engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: TMemo to hold more than 4k lines
« Reply #6 on: July 23, 2018, 08:54:01 pm »
I just did a quick test. Memo1.WordWrap:=not Memo1.WordWrap works fine here: Laz1.8.2 on Win32.

ricardo_sdl

  • New Member
  • *
  • Posts: 21
Re: TMemo to hold more than 4k lines
« Reply #7 on: July 23, 2018, 09:52:56 pm »
5k lines with 80 characters each worked fine, even Memo1.WordWrap:=not Memo1.WordWrap.
Environment:
Lazarus 1.8.0 r56594 FPC 3.0.4 x86_64-win64-win32/win64

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: TMemo to hold more than 4k lines
« Reply #8 on: July 23, 2018, 09:55:10 pm »
it might not be a problem with number of lines, but rather with amount of text.

Try TRichMemo instead of TMemo

alveselvis2

  • New Member
  • *
  • Posts: 10
Re: TMemo to hold more than 4k lines
« Reply #9 on: July 23, 2018, 09:58:40 pm »
I guess the problem was the MemoOnChange event, because doing Memo.Lines.BeginUpdate and EndUpdate, plus doing the changes in a TStringList before passing them to the Memo solved my problem.

Thank you for the tips

 

TinyPortal © 2005-2018