Solved

Using progressbar to show disk operation.

Posted on 1998-02-18
4
209 Views
Last Modified: 2010-04-04
This question has probably been asked before but here it goes.

How do one go about using a progressbar to show disk operation as in the following:

Copying of files, to show how much of the file has been copied,

0
Comment
Question by:delbrad
  • 2
4 Comments
 
LVL 2

Expert Comment

by:Waldek
ID: 1359569
You may use SHFileOperation . It show a progress window. If it is no way tell.
0
 

Author Comment

by:delbrad
ID: 1359570
Thanks for the quick response but that was not what I was looking for, I want to be able to use my own dialog with a progressbar...
0
 
LVL 2

Expert Comment

by:Waldek
ID: 1359571
OK. If You copy using BlockRead You must read by block. If You know number of block You may update progressbar
0
 
LVL 5

Accepted Solution

by:
inter earned 30 total points
ID: 1359572
If you copy file from you application, take this. Otherwise this does not help. Also you may want to enhance this. We worked before so no need to demand more points.

Bye friend, (and bye to all the other friends may this piece of code works!-no no I use it several times dont wory!)

Igor

{
  Copies a file from S to D, and if Pr <> nil updates it
}
procedure CopyFileX(Pr : TProgressBar ;SOffset : LongInt; S, D: String);
var
  Src, Dest : TFileStream;
  Ptr  : pointer;
  red  : longint;
begin
 Ptr:= nil;
 Src:= nil;
 Dest:= nil;
 try
  Src := TFileStream.Create(S, fmOpenRead);
  Src.Seek(SOffset, soFromBeginning);
  Dest:= TFileStream.Create(D, fmCreate or fmOpenWrite);
  if Pr <> nil then
  begin
    Pr.Max := Round(Dest.Size/1024);
    Pr.Position := 0;
  end;
  GetMem(Ptr, 32000);
  while Src.Position <> Src.Size do
  begin
    red := Src.Read(Ptr^, 32000);
    Dest.Write(Ptr^, red);
    if Pr <> nil then
      Pr.StepBy(Round(red/1024));
    Application.ProcessMessages;
  end;
 finally
  if Assigned(Ptr) then FreeMem(Ptr, 32000);
  if Assigned(Src) then Src.Free;
  if Assigned(Dest) then Dest.Free;
 end;
end;

0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

760 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

18 Experts available now in Live!

Get 1:1 Help Now