Sign in to follow this  
wease

I need a timer. How should I do this.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
"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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this