c++ 自定义类中如何使用settimer定时器
#include<windows.h>
#include
using namespace std;
#define ID_TIMER 100
void CALLBACK TimerProc(HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime );
int main()
{
int ret = SetTimer(NULL,ID_TIMER,1000,(TIMERPROC)TimerProc);
MSG msg;
while (1)
{
GetMessage(&msg, NULL, 0, 0);
DispatchMessage(&msg);
}
return 0;
}
void CALLBACK TimerProc(HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime )
{
KillTimer(NULL,idEvent); //如果你只想输出一次的话
cout << “hahahaha”;
}