UINT_PTR SetTimer( HWND hWnd,
UINT_PTR nIDEvent,
UINT uElapse,
TIMERPROC lpTimerFunc
);中的 回调函数 lpTimerFunc 能否是一个普通 C++ 类的普通成员函数呢.我 写了个类 CMyApp,
void GApp::Run()
{
MSG msg; // 设定定时器
SetTimer( NULL, 1, 1000, TimeProc ); // 这个 TimeProc 怎么化成 CMyApp 自己的处理函数呢 // 进入消息循环
while ( GetMessage( &msg, NULL, 0, 0 ) )
{
if ( msg.message == WM_TIMER )
{
DispatchMessage( &msg );
}
}
return 0;
}
UINT_PTR nIDEvent,
UINT uElapse,
TIMERPROC lpTimerFunc
);中的 回调函数 lpTimerFunc 能否是一个普通 C++ 类的普通成员函数呢.我 写了个类 CMyApp,
void GApp::Run()
{
MSG msg; // 设定定时器
SetTimer( NULL, 1, 1000, TimeProc ); // 这个 TimeProc 怎么化成 CMyApp 自己的处理函数呢 // 进入消息循环
while ( GetMessage( &msg, NULL, 0, 0 ) )
{
if ( msg.message == WM_TIMER )
{
DispatchMessage( &msg );
}
}
return 0;
}
那么也能在自己的类(普通类,非窗口类) 中设置定时器调用自己类中的回调函数了, 给讲讲吧
{
theApp.AppTimeProc() ;
}CMyApp::AppTimeProc()
{
printf("timer event") ;
}