|
-
Jun 4th, 2006, 10:18 PM
#1
Thread Starter
Lively Member
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
-
Jun 4th, 2006, 10:24 PM
#2
PowerPoster
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 :-)
-
Jun 4th, 2006, 10:31 PM
#3
Thread Starter
Lively Member
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
-
Jun 4th, 2006, 11:15 PM
#4
Re: progress bar
File copy with animation
VB Code:
Option Explicit
Private Type SHFILEOPSTRUCT
hWnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Boolean
hNameMappings As Long
lpszProgressTitle As String
End Type
Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
Private Const FO_COPY = &H2
Private Const FOF_ALLOWUNDO = &H40
Public Sub SHCopyFile(ByVal from_file As String, ByVal to_file As String)
Dim sh_op As SHFILEOPSTRUCT
With sh_op
.hWnd = 0
.wFunc = FO_COPY
.pFrom = from_file & vbNullChar & vbNullChar
.pTo = to_file & vbNullChar & vbNullChar
.fFlags = FOF_ALLOWUNDO
End With
SHFileOperation sh_op
End Sub
Private Sub cmdCopy_Click()
SHCopyFile txtFrom.Text, txtTo.Text
End Sub
Private Sub Form_Load()
Dim file_path As String
file_path = App.Path
If Right$(file_path, 1) <> "\" Then file_path = file_path & "\"
End Sub
-
Jun 4th, 2006, 11:24 PM
#5
Thread Starter
Lively Member
Re: progress bar
I'm not sure where to put my part for the first file to copy to the flopy
Reston
-
Jun 4th, 2006, 11:25 PM
#6
Thread Starter
Lively Member
Re: progress bar
I'm not sure where to put my path for the first file to copy to the floppy
Sorry
Reston
-
Jun 4th, 2006, 11:31 PM
#7
Re: progress bar
Do not double post.
in the code which my previous post, you need to use:
VB Code:
SHCopyFile "C:\Temp\a.txt", "A:\a.txt"
Ignore the cmdCopy_Click and form load methods which I gave in my previous post.
-
Jun 4th, 2006, 11:45 PM
#8
Thread Starter
Lively Member
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
-
Jun 5th, 2006, 04:18 AM
#9
PowerPoster
Re: progress bar
 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|