Re: David Cuny Window question regarding onTimer

new topic     » goto parent     » topic index » view thread      » older message » newer message

----- Original Message ----- 
From: "Sixs" <sixs at ida.net>
To: <EUforum at topica.com>
Subject: David Cuny Window question regarding onTimer


> 
> 
> Hello,
> 
> I was looking at your bounce program in an email. I am wondering what
> activates the program in a windows program?

A Windows program is a collection of small rouines that run when the events they
are associated with occur. You can think of it like these routines are just
sitting around waiting for their call up. Then they do their litle thing and go
back to waiting again.

You associate a routine with an event by using the setHandler() call. This call
links a routine, a type of event, and a control that the event happens to.
 
> I thought that the program had to be run either by buttons, menus, or
> statements.

Event though a Windows program may have these things, they don't CAUSE anything
unless they have routines linked to their events. For example...

Let's say I have a button called MyButton. I could then do something like ...

  procedure Click_MyButton(integer self, integer event, sequence parms)
     -- The user pressed the button.
     . . .
  end procedure

  -- Now link the button, event and routine together.
  setHandler(MyButton, w32HClick, routine_id("Click_MyButton"))


> What does this statement do? It seems to keep running over and over. I
> looked at the win documentation and didn't see the explanation.
> 
> onTimer[Win] = routine_id("Tick")

This is the old way of linking events to routines. In the newer Win32lib, this
has been replaced with ...

  setHandler(Win, w32HTimer, routine_id("Tick"))

But either way, this statement is a linking one. All it is saying that whenever
a timer event fires for the Win control, run the routine called 'Tick'.

> Is this sort of a loop ?

Not in itself. You need at least oe other statement to start the timer events
happening. Something like this ...

  setTimer(Win, 1, 5000)

which is saying that I want Timer #1 to be attached to the Win control and for
it to fire off every 5000 milliseconds (5 seconds). With both this and the
setHandler() call, the program will then run the 'Tick' routine every 5 seconds.

-- 
Derek

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu