Using a progressbar to show loading text in Memo

Is there a way to use a progress bar to show the progress of a file being loaded or save into/out a TMemo or RichText Component.
brad554Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jsextonCommented:
Try using BlockRead and increment the progress bar when each block is loaded.
0
xpherCommented:
Listening
0
interCommented:
Hi,

if you use the original LoadFromFile mechanism, there is no way. But you may do it with hand as jsexton suggested. However why do you need such thing? did you read text files that took Megabytes?

igor
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

intheCommented:
hi,
here is something earl f glynn posted a while ago using the tgauge component with a text file:

 the TGauge sample from Delphi -- even if you're reading a textfile.
 
If you're trying to read a textfile, you first need to know how big the file is. Open the file in binary mode just so you can use FileSize (See GetFileSize below).
 
Once you have the filesize, just count the bytes as you read them from the text file and occasionaly update the gauage to show progress.  See the code fragment below, ReadLoadData, that I regularly use to show progress reading a 500-900 KB file.  It's not perfect, but I think you'll find that it is a good enough heuristic approach to show progress while loading a file.
 
=====================================================================================
  FUNCTION GetFileSize(CONST FileName:  STRING):  LongInt;
    VAR
      RawFile    :  FILE OF Byte;
  BEGIN
    TRY
      AssignFile (RawFile, FileName);
      Reset (RawFile);
      RESULT := FileSize(RawFile);
      CloseFile (RawFile);
    EXCEPT
      ShowMessage ('Fatal Error:  Cannot open ' + FileName + ' (binary)');       Halt
    END
  END {GetFileSize};
 
 
 
 
  PROCEDURE ReadLoadData (VAR LoadGauge:  TGauge);
    VAR
      Buffer      :  ARRAY[1..8192] OF CHAR;
      ByteCount  :  LongInt;
      LineCount  :  LongInt;
      LoadFile    :  TextFile;
      FileName    :  STRING;
      NewRecord  :  TUnitRecord;
      OK          :  BOOLEAN;
      RecordDelta :  WORD;
      Size        :  LongInt;
      TextLine    :  STRING;
  BEGIN
    FileName := GetDBGADSalias + 'Megawatt\LOAD.TXT';
    Size := GetFileSize(FileName);
 
    {Use heuristic to estimate 1% of file}
    RecordDelta := Size DIV (100 * 102);    {approx 1% of file}
    IF  RecordDelta  < 10
    THEN RecordDelta := 10;                {lower bound of RecordDelta}
 
    TRY
      AssignFile (LoadFile, FileName);
      SetTextBuf(LoadFile, Buffer);
      Reset (LoadFile);                    {open the file}
    EXCEPT
      ShowMessage ('Fatal Error:  Cannot open ' + FileName + ' (text)');       Halt
    END;
 
    READLN (LoadFile, TextLine);    {burn the header line of comments}     ByteCount := 260;              {approx size of header}
    LineCount := 1;
 
    WHILE NOT EOF(LoadFile)
    DO BEGIN
      READLN (LoadFile, TextLine);
 
      ...
 
 
 
      INC (LineCount);    
      INC (ByteCount, LENGTH(TextLine)+2);    {Add 2 for CR + LF in binary file}
 
      {You may want to update every N lines, or use some other heuristic}       IF  LineCount MOD RecordDelta = 0
      THEN LoadGauge.Progress := ROUND(100 * ByteCount / Size);
 
    END;
 
    ...
    LoadGauge.Progress := 100;
    ...
    CloseFile (LoadFile);
 
  END {ReadLoadData};



Regards Barry
0
RBertoraCommented:
Following...
0
intheCommented:
hello
  did it not help ??
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
brad554Author Commented:
Sorry about the late response. Had no time to try out your reponse until now thanks for the help
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.