March 28, 2024, 03:13:42 PM

News:

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


Progress Bar

Started by GWS, January 23, 2012, 03:05:58 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

GWS

Hi,

Here's a little nugget from Sean circa 2003 ..  :)

It is in the archives, but buried away in a zip of several other programs .. it's worth the re-telling I think ..


' Progress Bar Example by Sean - 2003

setid "GWL_HINSTANCE",-6
setid "WS_VISIBLE",&H10000000
setid "WS_CHILD",&H40000000
setid "PBM_SETPOS",&H402
setid "PBM_SETRANGE",&H401

def win:dialog
def run:int
def pb:int
def pos:int

declare CreateProgressbar(parent:pointer,x:int,y:int,w:int,h:int,flags:int,id:int)

dialog win,0,0,320,100,@CAPTION,0,"Progress Bar Example",mainwindow
control win,"B,Close,245,50,60,25,0,1"
control win,"S,,10,50,150,25,@CTSCROLLHORIZ,2"
showdialog win

setscrollrange(win,2,0,100)
setscrollpos(win,2,75)

pb=CreateProgressbar(win,5,5,300,30,0,2)

'max=200
'min=0
' SendMessageA(pb,@PBM_SETRANGE,0,(max*65536)|min)
' You could send the above message to change the range of the progress bar

SendMessage(pb,@PBM_SETPOS,75,0)
' this sets progress bar to 75, since default range is 0 to 100 percentages are easy
run = 1
waituntil run = 0
closedialog win
end

sub mainwindow
select @CLASS
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
SendMessage(pb,@PBM_SETPOS,getscrollpos(win,2),0)
endselect
return

sub CreateProgressbar(parent:pointer,x:int,y:int,w:int,h:int,flags:int,id:int)
def hWnd:int
declare "user32",CreateWindowExA(ex:int,class:string,name:string,style:int,x:int,y:int,x1:int,y1:int,parent:int,id:int,hinstance:int,ed:int),int
hWnd=CreateWindowExA(0,"msctls_progress32","",268435456 | 1073741824 | flags,x,y,w,h,#parent,2024+id,0,0)
clear CreateWindowExA
return hWnd



all the best, :)

Graham
Tomorrow may be too late ..