Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
Posts: 16777133 Joined: Tue Apr 22, 2003 7:42 pm
Post
by BackupUser » Wed Feb 12, 2003 1:50 pm
Restored from previous forum. Originally posted by GPI .
It is possible to say windows, that windows send a "wakeup" message after a period of time.
for example like this
Code: Select all
wakemeup(100); = 1s
repeat
eventid=WaitWindowEvent()
select eventid
case #wakeup
debug "now i can do something"
wakemeup(100); wakeup again
...
endselect
until quit
I now, i can create a new thread, which waits and then send a message to the mainwindow, but it there no alternates...
PII 333, 256MB, Asus TNT2Ultra 32MB, AWE Gold 64 4MB
BackupUser
PureBasic Guru
Posts: 16777133 Joined: Tue Apr 22, 2003 7:42 pm
Post
by BackupUser » Wed Feb 12, 2003 2:07 pm
Restored from previous forum. Originally posted by dmoc .
Danilo's timers may help (check PureLibraries\UserLibraries\HighResTimer exists). Routines required are:
StartTimer( TimerNum, msDelay, @YourFunction() )
EndTimer(TimerNum)
Search on "timers" for more help.
BackupUser
PureBasic Guru
Posts: 16777133 Joined: Tue Apr 22, 2003 7:42 pm
Post
by BackupUser » Wed Feb 12, 2003 2:18 pm
Restored from previous forum. Originally posted by GPI .
that isn't what i want.
I have now a other solution from a other forum:
Code: Select all
If OpenWindow(0, 10, 10, 600, 400, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget, "Timer")
SetTimer_(WindowID(),1,2000,0)
Text.s = "2s are over"
;Windowhandle,TimerID,Timeout,Timerproc
Repeat
EventID.l = WaitWindowEvent()
If EventID = #PB_Event_CloseWindow
Quit = 1
EndIf
If EventID = #WM_TIMER
KillTimer_(WindowID(),1)
MessageRequester("Timer",Text,64)
Text = "5s are over"
SetTimer_(WindowID(),1,5000,0)
EndIf
Until Quit = 1
EndIf
End
thanks to Andreas (
http://www.pure-board.de )
PII 333, 256MB, Asus TNT2Ultra 32MB, AWE Gold 64 4MB
BackupUser
PureBasic Guru
Posts: 16777133 Joined: Tue Apr 22, 2003 7:42 pm
Post
by BackupUser » Wed Feb 12, 2003 3:19 pm
Restored from previous forum. Originally posted by plouf .
are you sure i try this example and i get "timeout" messagerequest's instantly
Christos
BackupUser
PureBasic Guru
Posts: 16777133 Joined: Tue Apr 22, 2003 7:42 pm
Post
by BackupUser » Wed Feb 12, 2003 4:19 pm
Restored from previous forum. Originally posted by GPI .
Do you mean the "3s are over"-Message?
It works under w98SE
PII 333, 256MB, Asus TNT2Ultra 32MB, AWE Gold 64 4MB
BackupUser
PureBasic Guru
Posts: 16777133 Joined: Tue Apr 22, 2003 7:42 pm
Post
by BackupUser » Wed Feb 12, 2003 4:23 pm
Restored from previous forum. Originally posted by plouf .
yes the "5s " message
Christos
BackupUser
PureBasic Guru
Posts: 16777133 Joined: Tue Apr 22, 2003 7:42 pm
Post
by BackupUser » Wed Feb 12, 2003 4:41 pm
Restored from previous forum. Originally posted by GPI .
That is no error.
Look at the code.
Exact this should happen.
UINT SetTimer(
HWND hwnd, // handle of window for timer messages
UINT idTimer, // timer identifier
UINT uTimeout, // time-out value
TIMERPROC tmprc // address of timer procedure
);
if the timerproc is 0, no subroutine will called. Only a message #wm_timer is created.
PII 333, 256MB, Asus TNT2Ultra 32MB, AWE Gold 64 4MB
BackupUser
PureBasic Guru
Posts: 16777133 Joined: Tue Apr 22, 2003 7:42 pm
Post
by BackupUser » Wed Feb 12, 2003 4:45 pm
Restored from previous forum. Originally posted by ricardo .
@GPI
Work fine here in XP
Its possible to do it in a different way:
SetTimer_(WindowID(),1,2000,@TimeOff())
and ofcourse have a procedure
Code: Select all
Procedure TimeOff()
KillTimer_(WindowID(),1)
MessageRequester("Timer",Text.s,64)
Text = "5s are over"
SetTimer_(WindowID(),1,5000,@TimeOff())
EndProcedure
Then you receive the timer in a procedure
Best Regards
Ricardo
Dont cry for me Argentina...
BackupUser
PureBasic Guru
Posts: 16777133 Joined: Tue Apr 22, 2003 7:42 pm
Post
by BackupUser » Wed Feb 12, 2003 6:35 pm
Restored from previous forum. Originally posted by plouf .
Correct if procedure to call is null is getting a timer event every 0 seconds ricardo's suggestion is correct and popup;s events every 5 second
Christos
BackupUser
PureBasic Guru
Posts: 16777133 Joined: Tue Apr 22, 2003 7:42 pm
Post
by BackupUser » Wed Feb 12, 2003 8:39 pm
Restored from previous forum. Originally posted by GPI .
@plouf
Both codes should do the same, show a message after a period of time. But you they, that the first code (with procedure-address=0) show the message with no waiting time. Or did i misunderstand you?
PII 333, 256MB, Asus TNT2Ultra 32MB, AWE Gold 64 4MB
BackupUser
PureBasic Guru
Posts: 16777133 Joined: Tue Apr 22, 2003 7:42 pm
Post
by BackupUser » Thu Feb 13, 2003 6:07 am
Restored from previous forum. Originally posted by plouf .
using your fiirst example the the "5s are over" requestor reappears as
soon as i close the previous one
while using ricardo's sugestion the "5s are over" requestor reappears
5 seconds after the previous (normal)
from Win32.chm
"If lpTimerFunc is NULL, the system posts a WM_TIMER message to the application queue. The hwnd member of the message's MSG structure contains the value of the hWnd parameter. "
i saw this ,and as i understand it says that send a WM_Timer immediatly
if procedure to call is null so i guess that with calling procedure is the correct way
btw using xp here
Christos
BackupUser
PureBasic Guru
Posts: 16777133 Joined: Tue Apr 22, 2003 7:42 pm
Post
by BackupUser » Thu Feb 13, 2003 7:24 am
Restored from previous forum. Originally posted by GPI .
Which operationsystem do you use?
On my Win98SE the first example works perfekt. The message only arrived every 5 sek.
PII 333, 256MB, Asus TNT2Ultra 32MB, AWE Gold 64 4MB
BackupUser
PureBasic Guru
Posts: 16777133 Joined: Tue Apr 22, 2003 7:42 pm
Post
by BackupUser » Thu Feb 13, 2003 12:16 pm
Restored from previous forum. Originally posted by plouf .
btw using xp here
Christos
BackupUser
PureBasic Guru
Posts: 16777133 Joined: Tue Apr 22, 2003 7:42 pm
Post
by BackupUser » Thu Feb 13, 2003 12:30 pm
Restored from previous forum. Originally posted by GPI .
ricardo had sayed, that the code work unter xp...
I love the windows....
PII 333, 256MB, Asus TNT2Ultra 32MB, AWE Gold 64 4MB
BackupUser
PureBasic Guru
Posts: 16777133 Joined: Tue Apr 22, 2003 7:42 pm
Post
by BackupUser » Fri Feb 28, 2003 9:39 pm
Restored from previous forum. Originally posted by GPI .
Please try this:
Code: Select all
If OpenWindow(0, 10, 10, 600, 400, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget, "Timer")
SetTimer_(WindowID(),1,2000,0)
Text.s = "2s are over"
;Windowhandle,TimerID,Timeout,Timerproc
Repeat
EventID.l = WaitWindowEvent()
If EventID = #PB_Event_CloseWindow
Quit = 1
EndIf
If EventID = #WM_TIMER and EventwParam()=1 ;1=TimerID
KillTimer_(WindowID(),1)
MessageRequester("Timer",Text,64)
Text = "5s are over"
SetTimer_(WindowID(),1,5000,0)
EndIf
Until Quit = 1
EndIf
End
PII 333, 256MB, Asus TNT2Ultra 32MB, AWE Gold 64 4MB