Results 1 to 9 of 9

Thread: progress bar

  1. #1

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

    progress bar

    Hi All

    I’m trying to have a progress bar show the progress of my file copy. I have some fairly large cnc programs that my app copies to a floppy. I’ve searched the forms and have see lots of good examples but don’t really get them. Any help would be great

    Thanks Reston

  2. #2
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    Re: progress bar

    Progress bars are simple enough things for you to make yourself if you so wished. You simply need X (the max value of the item the progress bar is for) and Y (the current value)...if X = 100 and Y =55 then the bar would be at 55% (X divided by 100 then multiplied by Y)...so you would take the width of whatever you're using as a progress bar (let's say an image) and divide it by 100 then multiply that by the 55 you got previously (notice the same algorhythm being used again to work out the width of the bar :-))...as long as you have set the .left of the image to where you want it to be, it should look like a proper progress bar :-)

  3. #3

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

    Re: progress bar

    Hi smUX

    Do you think an image box is the way to go or is this the way you like to do things.I guess i need a loop to look at how many bites are copied.Not sure about how to get at that but i wiil look around for some good examples.

    Reston

  4. #4
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Re: progress bar

    File copy with animation
    VB Code:
    1. Option Explicit
    2.  
    3. Private Type SHFILEOPSTRUCT
    4.     hWnd As Long
    5.     wFunc As Long
    6.     pFrom As String
    7.     pTo As String
    8.     fFlags As Integer
    9.     fAnyOperationsAborted As Boolean
    10.     hNameMappings As Long
    11.     lpszProgressTitle As String
    12. End Type
    13.  
    14. Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
    15.  
    16. Private Const FO_COPY = &H2
    17. Private Const FOF_ALLOWUNDO = &H40
    18.  
    19. Public Sub SHCopyFile(ByVal from_file As String, ByVal to_file As String)
    20.     Dim sh_op As SHFILEOPSTRUCT
    21.  
    22.     With sh_op
    23.         .hWnd = 0
    24.         .wFunc = FO_COPY
    25.         .pFrom = from_file & vbNullChar & vbNullChar
    26.         .pTo = to_file & vbNullChar & vbNullChar
    27.         .fFlags = FOF_ALLOWUNDO
    28.     End With
    29.  
    30.     SHFileOperation sh_op
    31. End Sub
    32.  
    33. Private Sub cmdCopy_Click()
    34.     SHCopyFile txtFrom.Text, txtTo.Text
    35. End Sub
    36.  
    37. Private Sub Form_Load()
    38.     Dim file_path As String
    39.     file_path = App.Path
    40.     If Right$(file_path, 1) <> "\" Then file_path = file_path & "\"
    41. End Sub
    CS

  5. #5

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

    Re: progress bar

    I'm not sure where to put my part for the first file to copy to the flopy

    Reston

  6. #6

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

    Re: progress bar

    I'm not sure where to put my path for the first file to copy to the floppy

    Sorry
    Reston

  7. #7
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Re: progress bar

    Do not double post.

    in the code which my previous post, you need to use:
    VB Code:
    1. SHCopyFile "C:\Temp\a.txt", "A:\a.txt"
    Ignore the cmdCopy_Click and form load methods which I gave in my previous post.
    CS

  8. #8

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

    Re: progress bar

    Thanks that works like a charm

    But one of the files is so small that the animation barley shows up. I think that is why I’m looking for the progress bar. I think that the code you gave me will work nicely for this large log file that I have in this app.

    Thanks
    Reston

  9. #9
    PowerPoster
    Join Date
    May 2006
    Location
    Location, location!
    Posts
    2,673

    Re: progress bar

    Quote Originally Posted by tiguy
    Do you think an image box is the way to go or is this the way you like to do things.
    I personally don't use progress bars at all, but if I did I would use the ones provided with VB (I think they're under common controls or something, you need to actually assign the ocx to your program so that you can use them)...an image box would definitely be original though and would be something different :-)

    It's just a possibility, an option you can take

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