Solved

ProgressBar with copyfile

Posted on 1998-12-12
7
1,497 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
Comment Utility
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
Comment Utility
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
Comment Utility
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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 20

Expert Comment

by:Madshi
Comment Utility
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
Comment Utility
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
Comment Utility
Dear waipahu
Either accept the answer or reject it.But do something
Venks
0
 

Author Comment

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

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

762 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

9 Experts available now in Live!

Get 1:1 Help Now