Progress Bars
BlitzMax Forums/BlitzMax Programming/Progress Bars
| ||
Could someone explain me why doesn't this code work? Strict Local window:TGadget=CreateWindow("My Window",50,50,240,100,,WINDOW_TITLEBAR) Local progbar:TGadget=CreateProgBar(10,10,200,20,window) Global count=0 While WaitEvent() count=count+1 If count<=50 UpdateProgBar progbar,count/50 EndIf Select EventID() Case EVENT_WINDOWCLOSE End End Select Wend |
| ||
Because there are no events firing. This SuperStrict Local MyWindow:TGadget=CreateWindow("Progress Bar Example", 40,40,400,400) Local MyProgBar:TGadget=CreateProgBar(10,20,370,20,MyWindow) CreateTimer 10 Repeat WaitEvent() Select EventID() Case EVENT_WINDOWCLOSE End Case EVENT_TIMERTICK Local t:Int=EventData() If t=50 End UpdateProgBar Myprogbar,t/50.0 End Select Forever End was taken from here |
| ||
You are waiting for an event in your while loop for each pass - the only event your app will get is the close event. Add a timer to trigger an event at a set interval and update your progress bar on the timer event :-Strict Local window:TGadget=CreateWindow("My Window",50,50,240,100,,WINDOW_TITLEBAR) Local progbar:TGadget=CreateProgBar(10,10,200,20,window) Global count=0 Global timer:TTimer = CreateTimer( 200 ) While WaitEvent() Select EventID() Case EVENT_WINDOWCLOSE End Case EVENT_TIMERTICK If count < 100 count = count + 1 UpdateProgBar progbar,count/100.0 EndIf End Select Wend |
| ||
Oops, tony beat me to it :) |
| ||
Ok, i'll try to modify the counter to a timer. Thank you all. |