tags:

views:

315

answers:

4

Hi,

I use TMemo to display long strings. I was very surprised that method : Memo1.loadfromfile('mem.txt') [mem.txt = 111 kB] took about 35 seconds, what is really really long time.

How can I make TMemo load strings in real time?

thanx

+3  A: 

Because WordWrap property was true...

lyborko
Is there some explanation for *why* that would have an effect?
Rob Kennedy
+2  A: 

:-) And you can try

try
  Memo1.Lines.BeginUpdate;
  Memo1.LoadFromFile('mem.txt');
finally
  Memo1.Lines.EndUpdate;
end;
DiGi
the part that corresponds with the code part in the finally should go right before the try. Not in the try. DisabledUpdates should go before the try. If DisabledUpdates never executes or fails for whatever reason, then EnableUpdates should not be called.
Lars Truijens
You probably mean BeginUpdate/EndUpdate. TStrings.LoadFromStream (called from LoadFromFile) already calls these.
Bruce McGee
The code above does not exist... (DisabledUpdates, EnableUpdates). However it looks nice ;-)
lyborko
Sorry I typed it from mind. DisableControls is in dataset + BeginUpdate = DisableUpdates :D
DiGi
The LoadFrom...() methods already call Begin/EndUpdate() internally. Calling them manually has no effect other than to increment/decrement the internal reference counter.
Remy Lebeau - TeamB
A: 

You did not say which version of Delphi you are using. In Delphi 2009 and later, TStrings is now Unicode aware, and thus has to perform additional processing when non-Unicode (Ansi/UTF) encoded files are being loaded.

Remy Lebeau - TeamB
Delphi 7.... and I use ANSI strings... I have never worked with Unicode strings, but what is widestring in Delphi 7 for? Does it provide Unicode string handling? /thats only by-the-way question/
lyborko
WideString is the only Unicode string type available in D2007 and earlier. In D2009, a new UnicodeString type was introduced, which is more efficient (referenced counted, copy on write, uses RTL memory manager, etc) than WideString (which is just a simple wrapper around the ActiveX/COM BSTR string type).
Remy Lebeau - TeamB
A: 

Any example of using Load from file using parallel arrays.

Patrick