#87417 - 2002-08-23 03:51 AM
Timer in kixforms
|
punkie
Getting the hang of it
Registered: 2002-06-23
Posts: 67
|
Could someone explain what the Timer object is used for in kixforms? I'm guessing it's instead of using loops.
If that's the case, i'm wondering what makes it better than loops.
|
Top
|
|
|
|
#87419 - 2002-08-23 04:18 AM
Re: Timer in kixforms
|
punkie
Getting the hang of it
Registered: 2002-06-23
Posts: 67
|
I see, what confused me was the 'interval' part in the object. It sounded like looping.
|
Top
|
|
|
|
#87421 - 2002-08-23 11:19 AM
Re: Timer in kixforms
|
Borte
Fresh Scripter
Registered: 2002-08-20
Posts: 29
Loc: Europe / Norway
|
The timer object is used to perform a task at an specified time interval.
Example: If you set the timer to an interval of 1000 then the timer event (OnTimer) will be executed every second. If you set it to 60000 then the timer will be executed every minute and so on...
I have used this to show timed dialog boxes to the user. When the timer is trigged the dialog boxe wil close just like the timeout value on the MessageBox() function.
Here is how i used it in my code:
code:
$tmrTimer = $Form.Timer() $tmrTimer.InterVal = 20000 ;20 seconds / time is given in milliseconds $tmrTimer.OnTimer = "tmrTimer_OnTimer()"
Function tmrTimer_OnTimer() $Form.Hide EndFunction
I hope this explains some of it..
|
Top
|
|
|
|
#87422 - 2002-08-23 02:42 PM
Re: Timer in kixforms
|
punkie
Getting the hang of it
Registered: 2002-06-23
Posts: 67
|
Hehe you're on the same time line as me Lonkero. It sounds pretty useful to me Have to check that code out.
|
Top
|
|
|
|
#87423 - 2002-08-23 03:52 PM
Re: Timer in kixforms
|
Chris S.
MM club member
   
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
Here's some code that takes advantage of the timer...
code:
; popup.kix Break On
$Form = CreateObject("Kixtart.Form")
$Form.BackColor = &00D0FFFF $Form.BorderStyle = 0 ; None $Form.ClientHeight = 1665/15 ; pixels = twips / 15 $Form.ClientLeft = 8580/15 $Form.ClientTop = 11745/15 $Form.ClientWidth = 2775/15 $Form.ScaleHeight = 1665/15 $Form.ScaleWidth = 2775/15 $Form.ShowInTaskbar = False ; Not ready yet !
$Label = $Form.Label $Label.Alignment = 2 ; Center $Label.Appearance = 0 ; Flat $Label.Caption = "Wasabi?" $Label.ForeColor = &80000008 $Label.Height = 195/15 $Label.Left = 480/15 $Label.Top = 660/15 $Label.Width = 1695/15
$Timer = $Form.Timer(500) ; 500 msecs $Timer.OnTimer = "Timer_Timer()" ;$Timer.Show
$Form.ForeColor = &00C00000 $Form.Line(2760/15,0,2760/15,1680/15) $Form.Line(0,0,0,1680/15) $Form.Line(0,0,2760/15,0)
; Move it below the visible screen (and a little just in case)
$Form.Top = $Form.Screen.Height + 10 ; Move it to the far right of the visible screen (minus a little, just for esthetics)
$Form.Top = $Form.Screen.Width - ($Form.Width + 10) ; We're gonna move it up
$DirectionIsUp = 1
$Form.Show While $Form.Visible $=Execute($Form.DoEvents) Loop
Exit 1
Function Timer_Timer() ; Move at 10 millisecond intervals (100 times a second, 3 times what the eye can see)
$Timer.Interval = 10 ; If it's moving up
If $DirectionIsUp ; Move it up 3 pixels every 10 milliseconds
$Form.Top = $Form.Top - 3 ; Move until the whole form is shown
If ($Form.Bottom < $Form.Screen.Height) ; This specifies how long it will stay shown (Unmoving)
$Timer.Interval = 3000 ; We're gonna move it down next...
$DirectionIsUp = 0
EndIf Else
; Move it down 3 pixels every 10 milliseconds
$Form.Top = $Form.Top + 3 ; Move until the whole form is shown (plus 10 twips to make sure it's hidden)
If $Form.Top >= $Form.Screen.Height
$Timer.Enabled = 0
$Form.Hide
EndIf
EndIf
EndFunction
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
0 registered
and 323 anonymous users online.
|
|
|