Author Topic: TMemo: Is there a way to disable updates while loading?  (Read 11153 times)

IPguy

  • Sr. Member
  • ****
  • Posts: 385
TMemo: Is there a way to disable updates while loading?
« on: April 16, 2011, 05:18:28 pm »
I'm loading sometimes a few hundred (or thousand) lines onto a TMemo and I do not need to bore the user with seeing all of those lines fly past them.

Is there a way to disable updates to the TMemo during my load, then enable updates and just show the loaded lines?  I'm also hoping this might decrease the time it takes to populate the tMemo as well.

The documentation (http://lazarus-ccr.sourceforge.net/docs/lcl/stdctrls/tmemo.html) did not provide me with any insights.

I see that there is both a tMemo.Refresh, which looks interesting, except I do not see an obvious way to disable updates.  I see a tMemo.Update, but again, the same question arises.

Thoughts?

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: TMemo: Is there a way to disable updates while loading?
« Reply #1 on: April 16, 2011, 05:21:18 pm »
Use TMemo.Lines.BeginUpdate before the update operation and TMemo.Lines.EndUpdate to finalize it. This will "freeze" your memo until the operation ends.

Code: [Select]
Memo1.Lines.BeginUpdate;

// code to update memo

Memo1.Lines.EndUpdate;
« Last Edit: April 16, 2011, 05:47:23 pm by typo »

IPguy

  • Sr. Member
  • ****
  • Posts: 385
Re: TMemo: Is there a way to disable updates while loading?
« Reply #2 on: April 16, 2011, 05:32:40 pm »
The auto properties suggestions for TMemo does not show either BeginUpdate or EndUpdate.  And Laz gives me an error when I use it.
Code: [Select]
import.pas(164,16) Error: identifier idents no member "BeginUpdate"
I do not find "BeginUpdate" or "EndUpdate" in the TMemo reference page or in any of the Properties, Methods or Events sub-pages.

Update: 0.9.31-30142-2.4.2 win32-Vista
« Last Edit: April 16, 2011, 05:35:25 pm by IPguy »

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: TMemo: Is there a way to disable updates while loading?
« Reply #3 on: April 16, 2011, 05:34:42 pm »
Sorry, I have edited the post above.

IPguy

  • Sr. Member
  • ****
  • Posts: 385
Re: TMemo: Is there a way to disable updates while loading?
« Reply #4 on: April 16, 2011, 05:37:19 pm »
It works and it's MUCH faster.
Thanks typo.

 

TinyPortal © 2005-2018