16,548
社区成员




#define TIMER_SLEEP 10000
DWORD WINAPI TimerThread(LPARAM pamaram)
{
CTestDlg *pDlg = (CTestDlg *)pamram;
ASSERT( pDlg != NULL );
UINT oldTickCount, newTickCount;
oldTickCount = GetTickCount();
while(TRUE)
{
while(TRUE)
{
newTickCount = GetTickCount();
if(newTickCount - oldTickCount >= TIMER_SLEEP)
{
oldTickCount = newTickCount;
break;
}
else
SwitchToThread();
}
// Call you function
pDlg->SetBitMap();
}
return 0;
}
VOID CALLBACK TimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
{
SYSTEMTIME st;
GetLocalTime(&st);
TCHAR buf[256] = {0};
_stprintf(buf, _T("%d:%d:%d\n"), st.wHour, st.wMinute, st.wSecond);
_tprintf(buf);
}
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
UINT nTimer = ::SetTimer(NULL, 0, 1000, (TIMERPROC)TimerProc);
MSG msg;
while(::GetMessage(&msg, NULL, 0, 0))
{
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
return 0;
}