Solved

Using progressbar to show disk operation.

Posted on 1998-02-18
4
214 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

749 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