Board index » delphi » displaying arbitrarily large text file in edit component of some kind

displaying arbitrarily large text file in edit component of some kind

Hello
I am using delphi 6. I wanted to display (not edit) a large text file in a
component, with scrollbars, of some kind, like richedit, memo, etc.

If I could catch events that scroll existing text in those components up or
down, I could create a dynamic loading routine, but I don't know how to
intercept those events that scroll the scrollbar, and those that get called
when someone uses the arrow keys.
Does anyone know how to intercept theseevents, or does anyone know how to
load an arbitrarily large text file (no more than maybe 500k in size) into
those components, or does anyone know of free components, that I could use
in a commercial application, for this?

Thanks,

Gino

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----

 

Re:displaying arbitrarily large text file in edit component of some kind


If you want to implement this yourself then take into considerationt that
you won't have a line count for the file, so some jiggery pokery will be
necessary to fake a line count in order to get the scroll bars roughly
right.

Since this is readonly you might consider faking such a "dynamic" edit
control by using TListView in virtual mode. A virtual listview is exactly
what you want except it;s really intended for lists. However if you set it
to not show the column header, use ViewStyle:=vsReport mode,  and only have
one column  then it will look just like an edit control. Virtual listviews
use the "listview.items.count" property to work out the scroll bars. You
will have make an estimate of the count and then each time the listview asks
for an item (in the Ondata event) you will have to work out whether you
should be displaying the last lines of the file. Remember to set the
listviews "OwnerData" property to true or it won't be virtual.

Alternatively you could derive a new TMemo and substitute a TStrings
decendant that handles the dynamic aspects. Because the TStrings object that
TMemo uses (TMemoStrings) has been made totally private by Borland you will
have to impement a wicked hack to do the substitution. Examining the private
TStrings object will also help you to write your own virtual TStrings
implementation. The wicked hack should look like this :

just above the implementation of the TVirtualMEmo cosntructor write this :

type
    TMemoCracker=class(TCustomEdit)
  private
    FLines: TStrings;
   end;

then the cosntructor should look like this :

constructor TVirtualMemo.create(AOwner : TComponent);
begin
    inherited create(AOwner);
    TMemoCracker(self).FLines.free;
    TMemoCracker(self).FLines:=TVirtualFileAccessingStrings.create;
end;

Greg

--

Delphi extension : open explorer for file/project/project group from the IDE
http://www.lorriman.demon.co.uk/programming/ExplIDE/explorerIDE.htm

and other goodies

Quote
"Gino Costa" <gco...@beld.net> wrote in message

news:3c129039_2@corp.newsgroups.com...
Quote
> Hello
> I am using delphi 6. I wanted to display (not edit) a large text file in a
> component, with scrollbars, of some kind, like richedit, memo, etc.

> If I could catch events that scroll existing text in those components up
or
> down, I could create a dynamic loading routine, but I don't know how to
> intercept those events that scroll the scrollbar, and those that get
called
> when someone uses the arrow keys.
> Does anyone know how to intercept theseevents, or does anyone know how to
> load an arbitrarily large text file (no more than maybe 500k in size) into
> those components, or does anyone know of free components, that I could use
> in a commercial application, for this?

> Thanks,

> Gino

> -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
> http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
> -----==  Over 80,000 Newsgroups - 16 Different Servers! =-----

Re:displaying arbitrarily large text file in edit component of some kind


Quote
"Gino Costa" <gco...@beld.net> wrote in message

news:3c129039_2@corp.newsgroups.com...

Quote
> Hello
> I am using delphi 6. I wanted to display (not edit) a large text file in a
> component, with scrollbars, of some kind, like richedit, memo, etc.

> If I could catch events that scroll existing text in those components up
or
> down, I could create a dynamic loading routine, but I don't know how to
> intercept those events that scroll the scrollbar, and those that get
called
> when someone uses the arrow keys.
> Does anyone know how to intercept theseevents, or does anyone know how to
> load an arbitrarily large text file (no more than maybe 500k in size) into
> those components, or does anyone know of free components, that I could use
> in a commercial application, for this?

Use a tMemo with ReadOnly set true. To load a file use the LoadFromFile
method of the memo's Lines property, e.g. aMemo.Lines.LoadFromFile
('c:\test.txt').

Re:displaying arbitrarily large text file in edit component of some kind


Quote
> > when someone uses the arrow keys.
> > Does anyone know how to intercept theseevents, or does anyone know how
to
> > load an arbitrarily large text file (no more than maybe 500k in size)
into
> > those components, or does anyone know of free components, that I could
use
> > in a commercial application, for this?

> Use a tMemo with ReadOnly set true. To load a file use the LoadFromFile
> method of the memo's Lines property, e.g. aMemo.Lines.LoadFromFile
> ('c:\test.txt').

I think he meant that he wants the ability to read portions of a 2gig file
without loading the whole lot, but as if the whole lot were loaded so that
the fact that the file is very large is transparent to the user.

Re:displaying arbitrarily large text file in edit component of some kind


Quote
"Greg Lorriman" <greg_lorri...@bigfoot.com> wrote in message

news:1007883273.6722.0.nnrp-02.9e98bd70@news.demon.co.uk...

Quote
> > > when someone uses the arrow keys.
> > > Does anyone know how to intercept theseevents, or does anyone know how
> to
> > > load an arbitrarily large text file (no more than maybe 500k in size)
> into
> > > those components, or does anyone know of free components, that I could
> use
> > > in a commercial application, for this?

> > Use a tMemo with ReadOnly set true. To load a file use the LoadFromFile
> > method of the memo's Lines property, e.g. aMemo.Lines.LoadFromFile
> > ('c:\test.txt').

> I think he meant that he wants the ability to read portions of a 2gig file
> without loading the whole lot, but as if the whole lot were loaded so that
> the fact that the file is very large is transparent to the user.

I believe the post said up to about 500KB. Upon reflection, tMemo won't do.
However tRichEdit will do, provided that MaxLength is set to an
appropriately large value. As far as not loading the entire file at one
time, IMO its wasted effort. Especially for files < 1MB.

Re:displaying arbitrarily large text file in edit component of some kind


Quote
> > I think he meant that he wants the ability to read portions of a 2gig
file
> > without loading the whole lot, but as if the whole lot were loaded so
that
> > the fact that the file is very large is transparent to the user.

> I believe the post said up to about 500KB. Upon reflection, tMemo won't
do.
> However tRichEdit will do, provided that MaxLength is set to an
> appropriately large value. As far as not loading the entire file at one
> time, IMO its wasted effort. Especially for files < 1MB.

You're right; I didn;t see "no more" for some reason. And I agree.

Re:displaying arbitrarily large text file in edit component of some kind


Hello
This is Gino
Thank you for responding. I wanted to ask, what is the biggest file a
TRichEdit component can load into memory? I read that the limit was like 75K
for win9x. And how would I handle a huge file bigger than that limit, if the
limit isn't hige?

Thanks,

Gino

Quote
"Greg Lorriman" <greg_lorri...@bigfoot.com> wrote in message

news:1007944363.17705.0.nnrp-08.9e98bd70@news.demon.co.uk...

Quote

> > > I think he meant that he wants the ability to read portions of a 2gig
> file
> > > without loading the whole lot, but as if the whole lot were loaded so
> that
> > > the fact that the file is very large is transparent to the user.

> > I believe the post said up to about 500KB. Upon reflection, tMemo won't
> do.
> > However tRichEdit will do, provided that MaxLength is set to an
> > appropriately large value. As far as not loading the entire file at one
> > time, IMO its wasted effort. Especially for files < 1MB.

> You're right; I didn;t see "no more" for some reason. And I agree.

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----

Re:displaying arbitrarily large text file in edit component of some kind


Hello
It's me Gino again.
I just did a TRichEdit test to see what the maximum length was for Win98 SE,
and it is 64k bytes. I know I'll be needing more than that if I add all the
features to my application i want. Can you help me load more than that in a
component for viewing, or suggest another component that I can use for ascii
plain text files?
Thanks,
Gino
Quote
"Greg Lorriman" <greg_lorri...@bigfoot.com> wrote in message

news:1007944363.17705.0.nnrp-08.9e98bd70@news.demon.co.uk...

Quote

> > > I think he meant that he wants the ability to read portions of a 2gig
> file
> > > without loading the whole lot, but as if the whole lot were loaded so
> that
> > > the fact that the file is very large is transparent to the user.

> > I believe the post said up to about 500KB. Upon reflection, tMemo won't
> do.
> > However tRichEdit will do, provided that MaxLength is set to an
> > appropriately large value. As far as not loading the entire file at one
> > time, IMO its wasted effort. Especially for files < 1MB.

> You're right; I didn;t see "no more" for some reason. And I agree.

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----

Re:displaying arbitrarily large text file in edit component of some kind


Quote
"Gino Costa" <gco...@beld.net> wrote in message

news:3c14eedf_4@corp.newsgroups.com...

Quote
> Hello
> It's me Gino again.
> I just did a TRichEdit test to see what the maximum length was for Win98
SE,
> and it is 64k bytes. I know I'll be needing more than that if I add all
the
> features to my application i want. Can you help me load more than that in
a
> component for viewing, or suggest another component that I can use for
ascii
> plain text files?

As I noted in my previous post, you must set the rich edit's MaxLength
property to a sufficiently large value. When it is set to zero the edit's
default is generally 64KB (although I think this depends on platform).

Re:displaying arbitrarily large text file in edit component of some kind


Ok.
Thanks.
According to the online help, leaving the value at zero ensures the maximum
length would be used, making the only reason to change it is to limit the
value yourself.
Gino

Quote
"Bruce Roberts" <b...@bounceitattcanada.xnet> wrote in message

news:ab7R7.3265$Q06.23071@tor-nn1.netcom.ca...

Quote

> "Gino Costa" <gco...@beld.net> wrote in message
> news:3c14eedf_4@corp.newsgroups.com...
> > Hello
> > It's me Gino again.
> > I just did a TRichEdit test to see what the maximum length was for Win98
> SE,
> > and it is 64k bytes. I know I'll be needing more than that if I add all
> the
> > features to my application i want. Can you help me load more than that
in
> a
> > component for viewing, or suggest another component that I can use for
> ascii
> > plain text files?

> As I noted in my previous post, you must set the rich edit's MaxLength
> property to a sufficiently large value. When it is set to zero the edit's
> default is generally 64KB (although I think this depends on platform).

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----

Re:displaying arbitrarily large text file in edit component of some kind


Quote
"Gino Costa" <gco...@beld.net> wrote in message

news:3c150eff$1_1@corp.newsgroups.com...

Quote
> Ok.
> Thanks.
> According to the online help, leaving the value at zero ensures the
maximum
> length would be used, making the only reason to change it is to limit the
> value yourself.

On this point the help is misleading. If you check carefully you will note
that help on MaxLength is for tCustomEdit, not specifically for tRichEdit.
You MUST set the MaxLength of tRichEdit if you want it to store more than
about 64KB (depending on platform).

Other Threads