Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9250797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:32:03+00:00 2026-06-18T10:32:03+00:00

I use the Delphi LoadFromFile function to insert Table1BLOBFIELD.LoadFromFile (‘C:\xxx.avi’) and the SaveToFile command

  • 0

I use the Delphi LoadFromFile function to insert Table1BLOBFIELD.LoadFromFile
(‘C:\xxx.avi’) and the SaveToFile command to retrieve.
This inserting/retrieving is rather timeconsuming (several minutes). It
would be nice if I could show a kind of progressbar (instead of only an
hourglass-shaped cursor).
When using SaveToFile I can perhaps use a timer and check the filesize
(although this doesn’t seem to work without threads). But this is no
solution for LoadFromFile.
Does anyone have a particular solution, a hint,…?
Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T10:32:05+00:00Added an answer on June 18, 2026 at 10:32 am

    Here a simple example of how to subclass TFileStream and how to add an OnProgress event to it:

    unit Unit1;
    
    interface
    
    uses
      SysUtils, Classes, Controls, Forms, XPMan, Db, ComCtrls, StdCtrls, AdoDB;
    
    type
      TStreamProgressEvent = procedure(Sender: TObject;
        Percentage: Single) of object;
    
      TProgressFileStream = class(TFileStream)
      private
        FOnProgress: TStreamProgressEvent;
        FProcessed: Int64;
        FSize: Int64;
      public
        procedure InitProgressCounter(ASize: Int64);
        function Read(var Buffer; Count: Integer): Integer; override;
        function Write(const Buffer; Count: Integer): Integer; override;
        property OnProgress: TStreamProgressEvent read FOnProgress
          write FOnProgress;
      end;
    
      TForm1 = class(TForm)
        ADOQuery1: TADOQuery;
        ADOQuery1ID: TAutoIncField;
        ADOQuery1Blob: TBlobField;
        Button1: TButton;
        ProgressBar: TProgressBar;
        procedure Button1Click(Sender: TObject);
      private
        procedure StreamProgress(Sender: TObject; Percentage: Single);
      end;
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.dfm}
    
    { TProgressFileStream }
    
    procedure TProgressFileStream.InitProgressCounter(ASize: Int64);
    begin
      FProcessed := 0;
      if ASize <= 0 then
        FSize := 1
      else
        FSize := ASize;
      if Assigned(FOnProgress) then
        FOnProgress(Self, 0);
    end;
    
    function TProgressFileStream.Read(var Buffer; Count: Integer): Integer;
    begin
      Result := inherited Read(Buffer, Count);
      Inc(FProcessed, Result);
      if Assigned(FOnProgress) then
        FOnProgress(Self, FProcessed / FSize);
    end;
    
    function TProgressFileStream.Write(const Buffer; Count: Integer): Integer;
    begin
      Result := inherited Write(Buffer, Count);
      Inc(FProcessed, Result);
      if Assigned(FOnProgress) then
        FOnProgress(Self, FProcessed / FSize);
    end;
    
    { TForm1 }
    
    procedure TForm1.Button1Click(Sender: TObject);
    var
      Stream: TProgressFileStream;
    begin
      ADOQuery1.Open;
      Stream := TProgressFileStream.Create('H:\Delphi\Blobtest.docx', fmOpenRead);
      try
        Stream.OnProgress := StreamProgress;
        Stream.InitProgressCounter(Stream.Size);
        ADOQuery1.Append;
        ADOQuery1Blob.LoadFromStream(Stream);
        ADOQuery1.Post;
      finally
        Stream.Free;
      end;
      Stream := TProgressFileStream.Create('H:\Delphi\Blobtest2.docx', fmCreate);
      try
        ADOQuery1.Last;
        Stream.OnProgress := StreamProgress;
        Stream.InitProgressCounter(ADOQuery1Blob.BlobSize);
        ADOQuery1Blob.SaveToStream(Stream);
      finally
        Stream.Free;
      end;
    end;
    
    procedure TForm1.StreamProgress(Sender: TObject; Percentage: Single);
    begin
      ProgressBar.Position := Round(Percentage * ProgressBar.Max);
    end;
    
    end.
    

    Although this OnProgress event is implemented on the file-side of the process, the actual progress that it represents is the overall process, including database communication.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need use Delphi to create an application about GPS almanac. Something like this:
I have tried to use delphi to send commands to the command prompt. However,
how to popup this form use delphi ? is ShellExecuteEx or ShellExecute can do
I use Delphi, but this is a question that I think is valid for
I am trying to use Delphi 2009's refactoring to extract an interface from a
When I compile our project use Delphi 2010 Trial, there has a fatal error
How would I be able to use Delphi to remove data from a memo
Trying to use GnuPG with Delphi (Win32). I need to sign some file with
We want to use Unicode with Delphi 2009 and Interbase, and found that to
I need to understand how to use the generic Delphi 2009 TObjectList . My

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.