Good information.

I now have a clock on my form.

Thank you.

IanB.



"Vesselin Bontchev" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> > Anyone know how to display a clock in a custom app?
>
> This is indeed not a trivial problem, if one is new to the PalmOS
platform. I've had to solve a related problem myself (not displaying a
timer, but doing something else "in parallel" while handling the controls of
the form), so I have researched the issue.
>
> Basically, the idea is the following:
>
> 1) In the event loop of your application, instead of
>
> EvtGetEvent (&event, evtWaitForever);
>
> use
>
> EvtGetEvent (&event, eventTimeout);
>
> where eventTimeout is a global variable, initialized with evtWaitForever.
>
> 2) As soon as the handler of your form that has to display the timer
receives control, set eventTimeout to something small - e.g.,
SysTicksPerSecond() or less. Don't forget to set it back to evtWaitForever
when you leave the form (i.e., on frmCloseEvent), or you'll drain batteries
unnecessarily. Setting this variable to something small will force the OS to
send you a nilEvent at least as often as the number of ticks specified in
the eventTimeout. You might (and probably will) get them more often that
that, though.
>
> 3) In the event handler of the form that has to display the timer,
intercept the nilEvent event. Every time you get it, check how much time has
passed since the last time you updated the timer. If the time passed is
sufficient to mandate updating of the timer (e.g., one second), you update
the timer; otherwise you do nothing.
>
> That's it. For further tips, see, for instance, this
>
> http://www.pikesoft.com/tips/how_to_do_regular_timed_events.htm
>
> or look at the OpenSource application TikTok; it displays various timers
on a form. You can get it from
>
> http://mikemccollister.com/palm/TikTokSource.zip
>
> Regards,
> Vesselin
>



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/

Reply via email to