I need a timer. How should I do this.

Started by
2 comments, last by wease 18 years, 10 months ago
I need a timer in an activeX control. There are a couple I could use but I'm not really sure how to implement either. There is a CWnd timer and a namespace System::Timers. I have declared this->SetTimer(1,200,0); this->OnTimer = &TimerProc ... void CactiveXtestCtrl::TimerProc(UINT_PTR nIDEvent) { } but I get this error error C2276: '&' : illegal operation on bound member function expression There is another way to do it using a call back function and passing it in the SetTimer function but I'm not sure how to do this. A third way would be to add an OnTimer event to my program but it is not listed in the AddEvent Wizard for the Ctrl Class. The other method is to use System::Timers::Timer. If anyone can provide a really simple example, then I don't not have to worry about the CWnd timer. However, I do not know anything about MC++ and was hoping that I could somehow just declare System::Timers::Timer in the mian control class and not have to have a separate class for it. I want to use the timer on an object declared in the main control class.
Advertisement
If "this" is a class derived from CWnd (or any underlying class) then you just have to call SetTimer to "activate" the timer and implement the window's/control's OnTimer message.
"this" is a class derived from CWnd (well, I think so anyway since this-> shows a list with the SetTimer function available).

I tried adding

afx_msg void OnTimer(
UINT_PTR nIDEvent
);

to the .h file and

void CactiveXtestCtrl::OnTimer( UINT_PTR nIDEvent)
{
tmp.Render();
}

to the .cpp file but I don't think this really is adding the event listener. It was so much easier to do with the old class wizard in VC++ 6. I've tried using class view to add the event but WM_TIMER is not listed as an option. Did I manually enter it wrong?
ok..figured out how to add the event. I don't really like getting used to this whole new visual studio but I suppose that is they way it goes with technology. Thanks for your help

This topic is closed to new replies.

Advertisement