RickG_99
asked on
Confused about CWnd::SetTimer
I'm trying to start a timer in a CView class. I used the "Add windows message handler" class wizard to create the function:
void CTestclientView::OnTimer(U INT nIDEvent)
{
// TODO: Add your...
CView::OnTimer(nIDEvent);
}
What is the correct call to start the timer? I'm trying to start the timer using:
m_n_Timer = SetTimer(1, 100, CTest1View::OnTimer);
But I get a compiler error:
cannot convert parameter 3 from 'void (unsigned int)' to 'void (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,unsigned long)'
I'm confused. the actual prototype for CWnd::SetTimer is
UINT SetTimer( UINT nIDEvent, UINT nElapse, void (CALLBACK EXPORT* lpfnTimer)(HWND, UINT, UINT, DWORD) );
But the class wizard created a function with only one parameter.
Should my OnTimer function have a prototype like above.
void (CALLBACK EXPORT* lpfnTimer)(HWND, UINT, UINT, DWORD)
All I want is a 1/10th of a second timer to do some screen updates.
Thanks for the help.
void CTestclientView::OnTimer(U
{
// TODO: Add your...
CView::OnTimer(nIDEvent);
}
What is the correct call to start the timer? I'm trying to start the timer using:
m_n_Timer = SetTimer(1, 100, CTest1View::OnTimer);
But I get a compiler error:
cannot convert parameter 3 from 'void (unsigned int)' to 'void (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,unsigned long)'
I'm confused. the actual prototype for CWnd::SetTimer is
UINT SetTimer( UINT nIDEvent, UINT nElapse, void (CALLBACK EXPORT* lpfnTimer)(HWND, UINT, UINT, DWORD) );
But the class wizard created a function with only one parameter.
Should my OnTimer function have a prototype like above.
void (CALLBACK EXPORT* lpfnTimer)(HWND, UINT, UINT, DWORD)
All I want is a 1/10th of a second timer to do some screen updates.
Thanks for the help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
There is no window created yet in the constructor. Call SetTimer in the OnCreate and KillTimer in the OnDestroy.
ASKER
Ahh... All is good now!!
Thanks so much for your help!
Thanks so much for your help!
ASKER
_AFXWIN_INLINE UINT CWnd::SetTimer(UINT nIDEvent, UINT nElapse, void (CALLBACK* lpfnTimer)(HWND, UINT, UINT, DWORD)) { ASSERT(::IsWindow(m_hWnd))
This is why I thouht I had the wrong parameters for my OnTimer function.
I'm calling SetTimer in the constructor for the CView class, is this a problem?
Am I asserting because the window isn't finished being constructed?
Again... THANKS A LOT for your help!
Rick