On May 31, 2007, at 12:21 AM, Frank Condello wrote:
> On 31-May-07, at 2:25 AM, Glenn L. Austin wrote:
>
>> On May 30, 2007, at 11:17 PM, Frank Condello wrote:
>>
>>> On 31-May-07, at 2:01 AM, Jim Wagner wrote:
>>>
>>>> Help,. I seem to be stuck!
>>>>
>>>> When you add a timer to a class in code by using the new operator,
>>>> how
>>>> to you access the timer's action event?
>>>
>>> Create a Timer subclass that implements the event, then create an
>>> instance of that subclass.
>>
>> What I did was create the Timer subclass that took a TimerHandler as
>> a handler with a method that took the timer as a parameter, in the
>> Timer subclass' action it calls the TimerHandler's handler method
>> with the instance as a parameter, then defined TimerHandler as a
>> class interface, then defined the class with a TimerHandler
>> interface.
>>
>> I know, a lot of work, but it made it easy to create timers in code
>> then handle them in the defining class simply by handling the
>> TimerHandler's method.
>
> Well, better than waiting for this:
> <http://www.realsoftware.com/feedback/nyadonvu>
> I guess ;) Though I suppose your workaround might not work out so
> well if you need the owning class to handle a bunch of different
> timer events. I mulled over a similar problem a while back when
> porting C code that used structs with function pointers - eventually
> I just gave in and started subclassing, it's the "RB way".
Actually, since I pass the timer instance into the handler, I can
compare instances in the handler to find the "correct" one, and then
do the appropriate task.
--
Glenn L. Austin <><
Computer Wizard and Race Car Driver
<glenn at austin-home dot com>
<http://www.austin-home.com/glenn/>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
|