3,881
社区成员
发帖
与我相关
我的任务
分享
#include <windows.h>
#include <iostream>
using namespace std;
static BOOL bExitApp = FALSE;
const UINT uiTimerID = 10;
TIMERPROC FooTimerFun( HWND, UINT, UINT, DWORD )
{
static int nCount = 0;
cout << "Timer Function , nCount = " << nCount ++ << endl;
if( nCount > 20 )
bExitApp = TRUE;
return 0;
}
int main()
{
MSG msgFoo;
SetTimer( NULL, uiTimerID, 100 , (TIMERPROC)FooTimerFun );
while( !bExitApp && GetMessage( &msgFoo , NULL , 0 , 0 ) )
{
TranslateMessage( &msgFoo );
DispatchMessage( &msgFoo );
}
KillTimer( NULL , uiTimerID );
return 0;
}