Solved

ProgressBar with copyfile

Posted on 1998-12-12
7
1,516 Views
Last Modified: 2008-03-10
I want to use a progressbar with the copyfile function.
I want to let users know the progress of copying a file.
How would I do this?
0
Comment
Question by:waipahu
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1350780
You would be better to use SHFileOperation - this has support for the progress bar display all built in.

Raymond
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1350781
Raymond is right. But if you need it for winNT only, you can use the API CopyFileEx. It's a little bit easier than the SHFileOperation, I think.

Regards... Madshi.
0
 

Author Comment

by:waipahu
ID: 1350782
What is SHFIleOperation? Sorry, new to delphi.
Can you give me a sample code?
Do you  mean i have to do a readblock and writeblock????
thanks
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 20

Expert Comment

by:Madshi
ID: 1350783
SHFileOperation is win32API. You'll find the documention in the win32.hlp file. Just write SHFileOperation into your editor and press F1.

Regards... Madshi.
0
 
LVL 1

Accepted Solution

by:
venks earned 10 total points
ID: 1350784
Dear waipahu
Look at the help file of TFileOperation Component Version 1 which encapsulates SHfileoperation of win32 API.You can downlaod the component from

URL: http://www.chez.com/herveroz 

Help file of the component
+------------------------------------------------------------------------------+
| TFileOperation Component Version 1.0                                         |
+------------------------------------------------------------------------------+
| Author: Hervé Roz                                                            |
| e-mail: hroz@chez.com                                                        |
+------------------------------------------------------------------------------+
| Description:                                                                 |
|   This component encapsulates the ShFileOperation API of Microsoft Windows.  |
| Performs a copy, move, rename, or delete operation on a file system object.  |
+------------------------------------------------------------------------------+
| Properties:                                                                  |
|   Source: String that contains the names of the source files, wildcard       |
|           filename (*.*) is accepted.                                        |
|           You can include several mask separeted by a ';'.                   |                                       |
|   Destination: String that specifies the destination for the moved, copied,  |
|                 or renamed file.                                             |
|   Mode:                                                                      |
|    -foCopy      Copies the files specified by pFrom to the location            |
|               specified by pTo.                                              |
|    -foDelete      Deletes the files specified by pFrom (pTo is ignored).         |
|    -foMove      Moves the files specified by pFrom to the location             |
|               specified by pTo.                                              |
|    -foRename      Renames the files specified by pFrom.                          |
|   Options:                                                                   |
|    -fofAllowUndo         Preserves undo information, if possible.            |
|    -fofConfirmMouse         Not implemented.                                    |
|    -fofFilesOnly         Performs the operation only on files if a wildcard  |
|                          filename (*.*) is specified.                        |
|    -fofMultiDestFiles    Indicates that the pTo member specifies multiple    |
|                          destination files (one for each source file) rather |
|                          than one directory where all source files are       |
|                          to be deposited.                                    |
|    -fofNoConfirmation    Responds with "yes to all" for any dialog box that  |
|                          is displayed.                                       |
|    -fofNoConfirmMkDir    Does not confirm the creation of a new directory    |
|                          if the operation requires one to be created.        |
|    -fofRenameOnCollision Gives the file being operated on a new name         |
|                          (such as "Copy #1 of...") in a move, copy,          |
|                          or rename operation if a file of the target name    |
|                          already exists.                                     |
|    -fofSilent            Does not display a progress dialog box.             |
|    -fofSimpleProgress    Displays a progress dialog box, but does not show   |
|                          the filenames.                                      |
|    -fofWantMappingHandle Not implemented.                                    |
|   Title: String to use as the title for a progress dialog box.               |
|          This member is used only if Options includes fofSimpleProgress.     |
|   AbortByUser: Value that receives True if the user aborted any file         |
|                operations before they were completed or FALSE otherwise.     |
|                                                                              |
| (*): Read only property                                                      |
+------------------------------------------------------------------------------+
| Methods:                                                                     |
|   function Execute: Performs the copy, move, rename, or delete operation.    |
|     Returns zero if successful or nonzero value if an error occurs.          |
+------------------------------------------------------------------------------+
| Events:                                                                      |
+------------------------------------------------------------------------------+

+------------------------------------------------------------------------------+
| Installation                                                                 |
+------------------------------------------------------------------------------+
| 1. Unzip the file to any directory you like, for instance                    |
|   C:\Delphi 3\Source\FileOper, ...                                           |
| 2. Start Delphi and close any projects and/or files                          |
| 3. From the menu, choose 'Components/Install Components...'                  |
| 4. In the dialog, click 'Browse'                                             |
| 5. Navigate to your chosen directory and select 'FileOper.pas'               |
| 6. Click OK the way back                                                     |
| 7. In the dialog you have now set the unit file                              |
| 8. Click OK to perform the install                                           |
+------------------------------------------------------------------------------+

+------------------------------------------------------------------------------+
| ******************************* IMPORTANT ********************************** |
+------------------------------------------------------------------------------+
|     This software is absolutely free. Use it and enjoy Delphi.               |
|     All I want is to know why and how you are using this                     |
|     software.                                                                |
|                                                                              |
|     Suggestions for improvement and fixes are always welcome,                |
|     although no guarantee is made when we'll implemement them.               |
|                                                                              |
|     If you do use this component, please drop me an email                    |
|     telling me how you used it.                                              |
|                                                                              |
|     For bug reports, suggestions, new versions etc. contact me:              |
|                                                                              |
|     e-mail: hroz@chez.com                                                    |
|     URL: http://www.chez.com/herveroz                                        |
|                                                                              |
+------------------------------------------------------------------------------+

0
 
LVL 1

Expert Comment

by:venks
ID: 1350785
Dear waipahu
Either accept the answer or reject it.But do something
Venks
0
 

Author Comment

by:waipahu
ID: 1350786
Sorry, been busy...
I'll try your recommendation...
Thanks again!

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

856 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