Solved

TMemo and TStringList limits

Posted on 2001-08-24
6
1,655 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

759 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