Solved

TMemo and TStringList limits

Posted on 2001-08-24
6
1,674 Views
Last Modified: 2012-08-14
I tried to load a HTML file into a TMemo and also into a TStringList.  The HTML file was 43kb.  When I loaded the fil into the TMemo, only about half the file was loaded and visible in the TMemo.  When I loaded the file into a TStringList via LoadFromFile() I again was missing a sizeable portion of the file.  When I analyzed the Capacity and Count properties after TStringList.LoadFromFile I had a Capacity of 288 and a Count of 200.  And yet approx. 30% of the file was missing from the StringList.

Can anyone explain why this happens?
0
Comment
Question by:Monroe406
6 Comments
 
LVL 5

Expert Comment

by:scrapdog
ID: 6424007
Did you write to the Capacity property at all?
0
 

Author Comment

by:Monroe406
ID: 6424029
>> Did you write to the Capacity property at all?

Nope.  Prior to the LoadFromFile the Capacity and Count were at 0.  After the LoadFromFile they were 288 and 200 respectively.
0
 
LVL 5

Expert Comment

by:scrapdog
ID: 6424040
This is probably something that would be easier to diagnose if I were to do it myself.  If you want, mail the HTML file to scrapdog@jvlnet.com, and I'll have a look.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 27

Expert Comment

by:kretzschmar
ID: 6424466
per default depending on the os the limit is 32K,

you can extend the limit of the memo up to 64K
using the EX_LIMITTEXT Message before loading

for larger files use a TRichedit, there the limit is default set to 64K,
but can extended up to 2GB

a sample follows

meikl ;-)
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 50 total points
ID: 6424495
sorry i meant the message EM_EXLIMITTEXT

a sample with a trichedit

procedure TForm1.Button1Click(Sender: TObject);
begin
  Richedit1.Perform(EM_EXLIMITTEXT,0,$FFFFF);  //1 MB
  if Opendialog1.Execute then
    Richedit1.Lines.LoadFromFile(Opendialog1.FileName);
  RichEdit1.SelStart := Length(RichEdit1.Text);
  Richedit1.SetFocus;
end;

you must add the richedit-unit in the uses-clause
(there is this message-constant declared)

meikl
0
 
LVL 6

Expert Comment

by:edey
ID: 6425056
meikl beat me to it, so I'll have to sugest another alternative. Try this snippet in a project with a TWebBrowser, a TEdit & a TButton:

procedure TForm1.Button1Click(Sender: TObject);
var
   doc : variant;
begin
     webBrowser1.navigate(edit1.text);
     while webBrowser1.Busy do
           application.ProcessMessages;
     doc := webBrowser1.Document;
     doc.body.innerText := doc.body.innerHTML;
end;

GL
Mike
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now