Recent

Author Topic: [SOLVED] Scroll to position/caret in RichMemo?  (Read 12038 times)

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: [SOLVED] Scroll to position/caret in RichMemo?
« Reply #15 on: March 24, 2016, 02:05:04 pm »
r4587 should take care of Search() problem

I'd recommend to use
Code: [Select]
match := RichMemo1.Search('Line 200', 0, RichMemo1.GetTextLen, []);

Since length(RichMemo1.Text) causes the whole text (which could be large) to be copied from the Memo to memory and then discarded right away as soon as length is identified.

RichMemo1.GetTextLen - returns the length of the text without copying it to memory.
« Last Edit: March 24, 2016, 02:10:58 pm by skalogryz »

Trenatos

  • Hero Member
  • *****
  • Posts: 535
    • MarcusFernstrom.com
Re: [SOLVED] Scroll to position/caret in RichMemo?
« Reply #16 on: March 24, 2016, 02:46:22 pm »
Works like a charm, thanks a bunch Skalogryz, and thanks for the GetTextLen, I've never seen that before.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: [SOLVED] Scroll to position/caret in RichMemo?
« Reply #17 on: March 24, 2016, 03:04:07 pm »
... and thanks for the GetTextLen, I've never seen that before.
IIRC it was introduced in TMemo, to prevent any unnecessary memory allocation/copying.

I presume it only matters when text amounts is huge and you're somewhere in the late 90s.
Modern hardware makes the use GetTextLen irrelevant :D

Trenatos

  • Hero Member
  • *****
  • Posts: 535
    • MarcusFernstrom.com
Re: [SOLVED] Scroll to position/caret in RichMemo?
« Reply #18 on: March 24, 2016, 03:23:29 pm »
Haha, ok, though I still prefer knowing to not knowing   ;)

 

TinyPortal © 2005-2018