I am still trying to get a ProgressBar to my copy program - no such luck!
All I need is a small tiny dialog window showing me a status bar and - if it is simple - the files being copied. I guess showing also an estimated time for finishing would make it too complicate.
Does anybody have some (simple) progressbar example codes he can share? I just try to get my head in the right direction ...
Hi
Here are a few examples in IBasic which should be easy to convert to EBasic. I copied them from my archives by filename and did not check each source so there may be duplicates. Some samples use buttons to do the job and others an API.
Hope this helps
Dennis
Thanks, Dennis!
I'll have a look to them later - just trying to repair my development machine from a crash ... :( sitting on my 12" notebook right now.
I played around with this examples and it looks like that all of them require special command packs. I couldn't compile any of them. :(
Are this codes IBASIC STD?
Yes they are - I had them in my IB Std archives and not in my Pro directories. The one which uses buttons to create a progress bar works well and is the approach I use. The API ones use the standard MS API's. Perhaps someone else can advise what libraries are required if any. IBasic Std did not have add-on packs. I cannot recall but if I remember correctly, you have to somehow link to the API somehow.
Off to Sunday breakfast (It's 8:30 am in South Africa) - will try to see if I can compile later
Dennis
Open up the examples that come with Emergence and load the "progressbar.eba" sample program ;)
Also the "controldemo.eba" sample program has a progress bar in it as well. Look through all of the examples, I did try and cover a lot of ground with them ;)
And here I was thinking that the EB examples where simply the old ones converted. To be honest, I never looked at them and have now only found them lurking in the projects directory. Mea culpa :)
Mea culpa 2! :)
I will see what I can make out of it! Thanks!
here is some code to use the system copy progress to show file being copied compile as windows
' // Shell File Operations
' const for wFunc
CONST FO_MOVE = 0x1
CONST FO_COPY = 0x2
CONST FO_DELETE = 0x3
CONST FO_RENAME = 0x4
' constants for fFlags
CONST FOF_MULTIDESTFILES = 0x1
CONST FOF_CONFIRMMOUSE = 0x2
CONST FOF_SILENT = 0x4 :' don't create progress/report
CONST FOF_RENAMEONCOLLISION = 0x8
CONST FOF_NOCONFIRMATION = 0x10 :' Don't prompt the user.
CONST FOF_WANTMAPPINGHANDLE = 0x20 :' Fill in SHFILEOPSTRUCT.hNameMappings Must be freed using SHFreeNameMappings
CONST FOF_ALLOWUNDO = 0x40 :' Uses Recycle bin for deletion if set
CONST FOF_FILESONLY = 0x80 :' on *.*, do only files
CONST FOF_SIMPLEPROGRESS = 0x100 :' means don't show names of files
CONST FOF_NOCONFIRMMKDIR = 0x200 :' don't confirm making any needed dirs
TYPE SHFILEOPSTRUCT
DEF hwnd AS INT
DEF wFunc AS INT
DEF pFrom AS POINTER
DEF pTo AS POINTER
DEF fFlags AS WORD
DEF fAnyOperationsAborted AS INT
DEF hNameMappings AS INT
DEF lpszProgressTitle AS POINTER:' only used if FOF_SIMPLEPROGRESS
ENDTYPE
DECLARE IMPORT, _SHFileOperation ALIAS SHFileOperationA(lpFileOp AS SHFILEOPSTRUCT),INT
' pointers for source and destination
def s,d:pointer
' strings for source and destination
def source,destination as string
' Source string use path to your source here
source="C:\\test2.mpg"
' Destination string use path to your source here
destination="D:\\test2.mpg"
' Pointer to Source string
s=source
' Pointer to Destination string
d=destination
' define our structure
def SHFileOp:SHFILEOPSTRUCT
' Fill in our structure for copy function
SHFileOp.wFunc=FO_COPY :'copyfile
SHFileOp.pFrom=s :' pointer for source
SHFileOp.pTo=d :' pointer for destination
' call function
_SHFileOperation(SHFileOp)
'delete pointers
delete s
delete d
end
Now that is more than I could ask for! :)
Thanks a lot, Pip1957. It was exactly what I was looking for from the beginning in my other post ... :D
Just a last question and I am quite for now: How do you set the fFlags such as: FOF_NOCONFIRMATION ???
I tried to add it with an @ sign but also without one behind the SHFileOp.wFunc=FO_COPY but it did not work.
You have to OR them together eg FOF_NOCONFIRMATION|FOF_FILESONLY
Sorry misread try SHFileOp.fFlags=FOF_NOCONFIRMATION
Yep, worked!
You made my day, Pip1957 :) ;) :D ;D
Nice to be able to offer help I have received lots in the past from this board CHEERS 8)
Quote from: Junner2003 on January 20, 2007, 08:49:26 PM
Does anybody have some (simple) progressbar example codes he can share? I just try to get my head in the right direction ...
Probably not what your looking for, but have you seen memmonitor.eba ? It has 3 progress bars that show the Physical RAM, Page File, and Memory Load in a small window.
So like the "Progress Bars" aren't really progress bars from the looks of it, but in reality just painted "Rectangles" that look basically like a simplistic 2-D progress bar control....
Quote from: Dennisc on January 20, 2007, 09:10:02 PM
Hi
Here are a few examples in IBasic which should be easy to convert to EBasic. I copied them from my archives by filename and did not check each source so there may be duplicates. Some samples use buttons to do the job and others an API.
Hope this helps
Dennis
I try to translated it from IBasic Std to IWBasic v3.0 Professional but it fails in the declarations. What's wrong here?
''Sample of how to create an API progress bar.
const GWL_HINSTANCE = -6
CONST WS_VISIBLE = 0x10000000
const WS_CHILD = 0x40000000
const PBM_SETPOS = 0x402
const PBM_SETRANGE = 0x401
def win:dialog
def run:int
def pb:int
def pos:int
declare IMPORT, "user32",CreateWindowExA(ex:int,class:string,name:string,style:int,x:int,y:int,x1:int,y1:int,parent:dialog,id:int,hinstance:int,ed:int),int
declare import, "user32",DestroyWindow(wnd:int),int
declare import, "user32",SendMessageA(wnd:int,message:int,wparam:int,lparam:int),int
run = 1
openwindow(win,0,0,320,100,@caption,0,"Progress Bar Sample", &mainwindow)
CONTROL(win,@BUTTON,"Close",245,50,60,25,0,1)
CONTROL(win,@SCROLLBAR,"",10,50,150,25,@ctscrollhoriz,2)
showdialog win
setscrollrange(win, 2, 0, 100) 'bereik [0..100]
setscrollpos(win,2,75) 'pos = 75
pb = CreateWindowExA(0,"msctls_progress32","",WS_VISIBLE | WS_CHILD,5,5,300,30,win,2026,0,0)
if(pb = 0)
closewindow(win)
end
endif
'SendMessageA(pb,PBM_SETRANGE,0,&HFF0000)
' You could send the above message to change the range of the progress bar, but the range is difficult to figure
' because the lparam (&HFF0000) is a combination of startrange(low word) and endrange(high word)
SendMessageA(pb,PBM_SETPOS,75,0)
'this sets progress bar to 75, since default range is 0 to 100 percentages are easy
waituntil run=0
'Remove Progress Bar from memory..
DestroyWindow(pb)
closedialog win
end
sub mainwindow()
select @MESSAGE
case @IDCLOSEWINDOW
run = 0
case @IDCONTROL
if(@CONTROLID = 1) then run = 0
case @idhscroll
select @CODE
case @SBTHUMBPOS:case @SBTHUMBTRACK
setscrollpos win,2,@QUAL
case @SBLINELEFT
setscrollpos win,2,(getscrollpos(win,2)-1)
case @SBLINERIGHT
setscrollpos win,2,(getscrollpos(win,2)+1)
case @SBPAGELEFT
setscrollpos win,2,(getscrollpos(win,2)-10)
case @SBPAGERIGHT
setscrollpos win,2,(getscrollpos(win,2)+10)
endselect
SendMessageA(pb,PBM_SETPOS,getscrollpos(win,2),0)
endif
endselect
return
Compiling Resources...
No Errors
Compiling...
apiprogressbar.eba
File: c:\users\public\documents\development\iwbasic\projects\roundtable\progressbars\apiprogressbar.eba (14) Error: syntax error - "
File: c:\users\public\documents\development\iwbasic\projects\roundtable\progressbars\apiprogressbar.eba (14) Error: syntax error - ,
File: c:\users\public\documents\development\iwbasic\projects\roundtable\progressbars\apiprogressbar.eba (14) Error: syntax error - ,
File: c:\users\public\documents\development\iwbasic\projects\roundtable\progressbars\apiprogressbar.eba (14) Error: syntax error - ,
File: c:\users\public\documents\development\iwbasic\projects\roundtable\progressbars\apiprogressbar.eba (14) Error: syntax error - ,
File: c:\users\public\documents\development\iwbasic\projects\roundtable\progressbars\apiprogressbar.eba (14) Error: syntax error - ,
File: c:\users\public\documents\development\iwbasic\projects\roundtable\progressbars\apiprogressbar.eba (14) Error: syntax error - ,
File: c:\users\public\documents\development\iwbasic\projects\roundtable\progressbars\apiprogressbar.eba (14) Error: syntax error - ,
File: c:\users\public\documents\development\iwbasic\projects\roundtable\progressbars\apiprogressbar.eba (14) Error: syntax error - ,
File: c:\users\public\documents\development\iwbasic\projects\roundtable\progressbars\apiprogressbar.eba (14) Error: Undefined variable WINDOW
File: c:\users\public\documents\development\iwbasic\projects\roundtable\progressbars\apiprogressbar.eba (14) Error: syntax error - ,
File: c:\users\public\documents\development\iwbasic\projects\roundtable\progressbars\apiprogressbar.eba (9) Warning: Unreferenced variable 'win'
File: c:\users\public\documents\development\iwbasic\projects\roundtable\progressbars\apiprogressbar.eba (10) Warning: Unreferenced variable 'run'
File: c:\users\public\documents\development\iwbasic\projects\roundtable\progressbars\apiprogressbar.eba (11) Warning: Unreferenced variable 'pb'
File: c:\users\public\documents\development\iwbasic\projects\roundtable\progressbars\apiprogressbar.eba (12) Warning: Unreferenced variable 'pos'
Error(s) in compiling c:\users\public\documents\development\iwbasic\projects\roundtable\progressbars\apiprogressbar.eba
Build Failed
Techno,
You are declaring your window as a "dialog" window, and then opening it as a "window"
I reckon changing this to a DIALOG window will sort you out
Brian
Quote from: Brian Pugh on May 26, 2015, 03:47:18 AM
Techno,
You are declaring your window as a "dialog" window, and then opening it as a "window"
I reckon changing this to a DIALOG window will sort you out
Brian
Brain
I don't understand what you said
def win:dialog <- Dialog
openwindow(win,0,0,320,100,@caption,0,"Progress Bar Sample", &mainwindow) <- Opened as Window not Dialog
closedialog win <- Closing as Dialog
case @IDCLOSEWINDOW <- Closing as Window
Hope this helps you to see the problem. You either need to create it as either a window or a dialog not a weird mixture of both.
Bill
Techno,
Here's a working version from your sample above. And please use IWB to compile this!
Added a bit of colour to the dialog background
Brian
'Sample of how to create an API progress bar
CONST GWL_HINSTANCE=-6
CONST WS_VISIBLE=0x10000000
CONST WS_CHILD=0x40000000
CONST PBM_SETPOS=0x402
CONST PBM_SETRANGE=0x401
CONST WM_CTLCOLORDLG=0x136
DECLARE IMPORT,CreateWindowExA(ex:int,classx:string,name:string,style:int,x:int,y:int,x1:int,y1:int,parent:dialog,id:int,hInstance:int,ed:int),int
DECLARE IMPORT,DestroyWindow(hWnd:int),int
DECLARE IMPORT,SendMessageA(hWnd:int,message:int,wparam:int,lparam:int),int
DECLARE IMPORT,CreateSolidBrush(crColor:INT),INT
DIALOG d1
INT run=1,pb
CREATEDIALOG d1,0,0,320,100,@CAPTION,0,"Progress Bar Sample",&mainwindow
CONTROL d1,@BUTTON,"Close",245,50,60,25,0,1
CONTROL d1,@SCROLLBAR,"",10,50,150,25,@CTSCROLLHORIZ,2
CONTROL d1,@STATIC,"Use cursor keys to set progress bar",40,20,200,20,0x5000010B,3
SHOWDIALOG d1
'SendMessageA(pb,PBM_SETRANGE,0,&HFF0000)
' You could send the above message to change the range of the progress bar, but the range is difficult to figure
' because the lparam (&HFF0000) is a combination of startrange(low word) and endrange(high word)
waituntil run=0
'Remove Progress Bar from memory
DestroyWindow(pb)
closedialog d1
END
sub mainwindow(),INT
select @MESSAGE
CASE @IDINITDIALOG
CENTERWINDOW d1
setscrollrange(d1,2,0,100)
setscrollpos(d1,2,75) 'pos = 75
pb=CreateWindowExA(0,"msctls_progress32","",WS_VISIBLE|WS_CHILD,5,5,300,30,d1,2026,0,0)
'this sets progress bar to 75, since default range is 0 to 100 percentages are easy
SendMessageA(pb,PBM_SETPOS,75,0)
' Colour the dialog window
CASE WM_CTLCOLORDLG
RETURN CreateSolidBrush(RGB(121,150,222))
CASE @IDCLOSEWINDOW
run=0
CASE @IDCONTROL
IF(@CONTROLID=1) then run = 0
CASE @idhscroll
SELECT @CODE
CASE @SBTHUMBPOS
CASE @SBTHUMBTRACK
setscrollpos d1,2,@QUAL
CASE @SBLINELEFT
setscrollpos d1,2,(getscrollpos(d1,2)-1)
CASE @SBLINERIGHT
setscrollpos d1,2,(getscrollpos(d1,2)+1)
CASE @SBPAGELEFT
setscrollpos d1,2,(getscrollpos(d1,2)-10)
CASE @SBPAGERIGHT
setscrollpos d1,2,(getscrollpos(d1,2)+10)
endselect
SendMessageA(pb,PBM_SETPOS,getscrollpos(d1,2),0)
endselect
return 0
ENDSUB