Okay, after checking out the links, I found and cleaned up some code from "Peter" (a moderator in a different forum).
Here's what I came up with, which works perfectly for my needs. Hope someone else can make use of it!
Code: Select all
#CopyFileWithProgressGadget=2000
#PROGRESS_CONTINUE=0
#PROGRESS_CANCEL=1
Global CopyFileWithProgressState
Global CopyFileWithProgressSource$
Global CopyFileWithProgressTarget$
Procedure.l CopyFileProgressCallback(TotalFileSize.q,TotalBytesTransferred.q,StreamSize.q,StreamBytesTransferred.q,dwStreamNumber.l,dwCallbackReason.l,hSourceFile.l,hDestinationFile.l,lpData.l)
SetGadgetState(#CopyFileWithProgressGadget,(TotalBytesTransferred*100)/TotalFileSize)
ProcedureReturn CopyFileWithProgressState
EndProcedure
Procedure CopyFileWithProgress_Thread(null)
CopyFileWithProgressState=#PROGRESS_CONTINUE
CopyFileEx_(@CopyFileWithProgressSource$,@CopyFileWithProgressTarget$,@CopyFileProgressCallback(),0,Flag,0)
SetGadgetState(#CopyFileWithProgressGadget,0) ; Clear ProgressBarGadget when copy is done, to avoid confusion.
EndProcedure
If OpenWindow(0,100,100,120,100,"Copy")
ProgressBarGadget(#CopyFileWithProgressGadget,10,10,100,20,1,100)
ButtonGadget(1,10,40,100,20,"Copy")
ButtonGadget(2,10,65,100,20,"Cancel")
Repeat
Event=WaitWindowEvent()
If Event=#PB_Event_Gadget
Select EventGadget()
Case 1
CopyFileWithProgressSource$="S:\1-GB-Video.vob"
CopyFileWithProgressTarget$="T:\"+GetFilePart(CopyFileWithProgressSource$)
CreateThread(@CopyFileWithProgress_Thread(),0) ; This starts the copy.
Case 2
CopyFileWithProgressState=#PROGRESS_CANCEL ; This cancels the copy.
EndSelect
EndIf
Until Event=#PB_Event_CloseWindow
EndIf