Results 1 to 5 of 5

Thread: ((Resolved)) progress bar with file copy Help

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2001
    Location
    Ca
    Posts
    124

    Smile ((Resolved)) progress bar with file copy Help

    Hi everone

    I need some help trying to figure out the whole file copy with a progress bar. Can anyone help.

    ive see some code for vb6 that makes the progress bar move based on the file size.

    Thanks for any help

    reston




    Last edited by tiguy; Apr 24th, 2004 at 12:03 AM.

  2. #2
    Addicted Member
    Join Date
    Jun 2002
    Posts
    211
    what type of file, and how are you copying it

    Simon

  3. #3
    Fanatic Member laserman's Avatar
    Join Date
    Jan 2002
    Location
    Wales U.K
    Posts
    775
    This is only a little demo I did and is not a true Filecopy.

    Hope this gives you a start though.

    If you have some time I will do a proper one later.

    Cheers
    Attached Files Attached Files

  4. #4
    Fanatic Member Bombdrop's Avatar
    Join Date
    Apr 2001
    Location
    St Helens, England, UK
    Posts
    667
    Try this this will show the progress rate of the file.

    place in a Bas Mod.
    VB Code:
    1. '=======================================================================
    2. 'Title              :Module1
    3. 'System             :Project1
    4. '=======================================================================
    5. 'Copyright          :© Albion Software
    6. 'Date               :23/04/2004
    7. 'Author             :©BomdBrop
    8. 'Technical Reviewer :
    9. 'Purpose            :
    10. '=======================================================================
    11. Option Explicit
    12.  
    13. Private Const FO_COPY = &H2&
    14.  
    15. Private Const FOF_NOCONFIRMATION = &H10&
    16.  
    17. Private Const FOF_SILENT = &H4& 'Progress not visible
    18.  
    19.  
    20. Private Type SHFILEOPSTRUCT
    21.     hwnd As Long
    22.     wFunc As Long
    23.     pFrom As String
    24.     pTo As String
    25.     fFlags As Integer
    26.     fAnyOperationsAborted As Long
    27.     hNameMappings As Long
    28.     lpszProgressTitle As String
    29. End Type
    30.  
    31. Private Declare Sub CopyMemory Lib "Kernel32" Alias "RtlMoveMemory" (hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long)
    32. Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As Any) As Long
    33.    
    34. Public Function CopyFile(FormHwd As Long, Source As String, Dest As String, _
    35.     AskOverwrite As Boolean, Visib As Boolean) As Boolean
    36.     Dim lenFileop As Long
    37.     Dim foBuf() As Byte
    38.     Dim fileop As SHFILEOPSTRUCT
    39.     lenFileop = LenB(fileop)
    40.     ReDim foBuf(1 To lenFileop)
    41.     With fileop
    42.         .hwnd = FormHwd
    43.         .wFunc = FO_COPY
    44.         .pFrom = Source & vbNullChar & vbNullChar & vbNullChar
    45.         .pTo = Dest & vbNullChar & vbNullChar
    46.        
    47.         If AskOverwrite = False Then .fFlags = FOF_NOCONFIRMATION 'no ask to overwrite
    48.         If Visib = False Then .fFlags = .fFlags Or FOF_SILENT 'not visible
    49.            
    50.         .lpszProgressTitle = "Copying " & Dest & vbNullChar & vbNullChar
    51.     End With
    52.    
    53.     Call CopyMemory(foBuf(1), fileop, lenFileop)
    54.     Call CopyMemory(foBuf(19), foBuf(21), 12)
    55.    
    56.    
    57.     CopyFile = SHFileOperation(foBuf(1)) = 0
    58.    
    59.  
    60. End Function

    place in a form.

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Command1_Click()
    4. CopyFile Me.hwnd, "U:\Books\VB.Classic Help.chm", _
    5.     "C:\Documents and Settings\sburrows\Desktop\test.chm", True, True
    6. End Sub

    hope this helps
    Last edited by Bombdrop; Apr 23rd, 2004 at 08:32 AM.

  5. #5

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width