Restored from previous forum. Originally posted by cYanide.
hi today ive been codeing my first pb app a mp3 player thing but i have a problem with progress bars. it only seems to update when the mosue is moving within the app..
Result.f = (MovieStatus()/MovieLength())*200
SetGadgetState(4, Round(Result,0))
Mp3Current = MovieStatus()
thats called in the loop.. any ideas?:)
{cYanide}
need a lil help please :)
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Pupil.
Something like that, you need to check the syntax because i haven't tested the code.
Another method would be to put that update stuff in a thread, check out the thread library in the manual.
Do you use WaitWindowEvent()? in that case read about what this command does -it halts the progarm untill an event occurs, like moving the mouse about for example. If you want the event loop to run constantly you would have to construct it like this:Originally posted by cYanide
hi today ive been codeing my first pb app a mp3 player thing but i have a problem with progress bars. it only seems to update when the mosue is moving within the app..
Result.f = (MovieStatus()/MovieLength())*200
SetGadgetState(4, Round(Result,0))
Mp3Current = MovieStatus()
thats called in the loop.. any ideas?:)
Code: Select all
repeat
event.l = windowevent()
if event
select event
case #PB_EventMenu
...
endselect
else
; do your stuff here
Result.f = (MovieStatus()/MovieLength())*200
SetGadgetState(4, Round(Result,0))
Mp3Current = MovieStatus()
; Next line important so you don't take all
; CPU time.
Delay(1)
endif
until event = #PB_EventCloseWindow
Another method would be to put that update stuff in a thread, check out the thread library in the manual.
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by cYanide.
Well its like not within the select case
Repeat
If Mp3State = 1
Result.f = (MovieStatus()/MovieLength())*200
SetGadgetState(4, Round(Result,0))
Mp3Current = MovieStatus()
EndIf
Select WaitWindowEvent()
etc
so i dont really see why it wont update constantly
{cYanide}
Well its like not within the select case
Repeat
If Mp3State = 1
Result.f = (MovieStatus()/MovieLength())*200
SetGadgetState(4, Round(Result,0))
Mp3Current = MovieStatus()
EndIf
Select WaitWindowEvent()
etc
so i dont really see why it wont update constantly
{cYanide}
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by freak.
The problem is, that WaitWindowEvent() halts the program until an event occurs.
So only if the mouse is over your Window, this cal happen (in this case, it's a Mouse Move Event)
As Pupil says, just replace it with WindowEvent().
But be sure to add 'Delay(1)' before the 'Until ...' Line.
(this prevents your loop from running really fast, and so take all CPU Time)
Timo
The problem is, that WaitWindowEvent() halts the program until an event occurs.
So only if the mouse is over your Window, this cal happen (in this case, it's a Mouse Move Event)
As Pupil says, just replace it with WindowEvent().
But be sure to add 'Delay(1)' before the 'Until ...' Line.
(this prevents your loop from running really fast, and so take all CPU Time)
Timo
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Paul.
Read the docs...
WaitWindowEvent() waits for an event to occurs then updates window
WindowEvent() returns immediately
----------
Visit the PB Resources Site at http://www.reelmediaproductions.com/pb
Read the docs...
WaitWindowEvent() waits for an event to occurs then updates window
WindowEvent() returns immediately
----------
Visit the PB Resources Site at http://www.reelmediaproductions.com/pb
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Berikco.
You can also add a timer, so you're progress bar is not updated 500 times a second.
If you want to do more with Settimer(), display counter for elapsed playtime e.g. , i think CallBack is only way.
Regards,
Berikco
http://www.benny.zeb.be
You can also add a timer, so you're progress bar is not updated 500 times a second.
If you want to do more with Settimer(), display counter for elapsed playtime e.g. , i think CallBack is only way.
Code: Select all
Global hwnd
hwnd= OpenWindow(1, 200, 100, 673, 155 ,#PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget| #PB_Window_SizeGadget,"PB Window 1")
;
If hwnd
SetTimer_(hWnd,1,200,0) ; 200 ms timer
Repeat
Event=WaitWindowEvent()
Select Event
Case #WM_TIMER
Debug "200 ms timer"
EndSelect
Until Event=#PB_Event_CloseWindow
EndIf
;
EndBerikco
http://www.benny.zeb.be
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm