April 19, 2024, 03:24:15 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Does any1 have some ProgressBar examples?

Started by Junner2003, January 20, 2007, 08:49:26 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Junner2003

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 ...

Dennisc

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
Failure is only the opportunity to begin again more intelligently
www.denniscomninos.com

Junner2003

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.

Junner2003

January 20, 2007, 11:12:33 PM #3 Last Edit: January 20, 2007, 11:32:47 PM by Junner2003
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?

Dennisc

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
Failure is only the opportunity to begin again more intelligently
www.denniscomninos.com

Ionic Wind Support Team

Open up the examples that come with Emergence and load the "progressbar.eba" sample program ;)
Ionic Wind Support Team

Ionic Wind Support Team

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 ;)
Ionic Wind Support Team

Dennisc

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 :)
Failure is only the opportunity to begin again more intelligently
www.denniscomninos.com

Junner2003

Mea culpa 2! :)
I will see what I can make out of it! Thanks!

Pip1957

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

Junner2003

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.

Pip1957

You have to OR them together eg FOF_NOCONFIRMATION|FOF_FILESONLY

Pip1957

Sorry misread try SHFileOp.fFlags=FOF_NOCONFIRMATION

Junner2003

Yep, worked!
You made my day, Pip1957  :)  ;)  :D  ;D

Pip1957

Nice to be able to offer help I have received lots in the past from this board CHEERS 8)

redea30591

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....

Techno

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

Brian

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

Techno

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

billhsln

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
When all else fails, get a bigger hammer.

Brian

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