1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
#include <windows.h>
#include <iostream>
#define POLL_TIMER 1
#define RND_TIMER 2
#define END_TIMER 3
UINT PollingTimerId (0);
UINT RndTimerId (0);
UINT EndTimerId (0);
VOID CALLBACK PollingTimerProc(HWND /*hWnd*/, UINT /*nMsg*/, UINT /*nIDEvent*/, DWORD /*dwTime*/)
{
std::cout << "Polling..." << std::endl;
}
VOID CALLBACK RandomTimerProc(HWND hWnd, UINT /*nMsg*/, UINT /*nIDEvent*/, DWORD /*dwTime*/)
{
std::cout << "Random Timer..." << std::endl;
//Kill the timer so it only fires once.
KillTimer(hWnd, RndTimerId);
}
VOID CALLBACK EndTimerProc(HWND /*hWnd*/, UINT /*nMsg*/, UINT /*nIDEvent*/, DWORD /*dwTime*/)
{
std::cout << "Ending..." << std::endl;
KillTimer(NULL, PollingTimerId);
KillTimer(NULL, EndTimerId);
PostQuitMessage (0) ;
}
int main(int /*argc*/, char /**argv[]*/)
{
PollingTimerId = SetTimer(NULL, POLL_TIMER, 1000, &PollingTimerProc);
// todo: create a random time interval
RndTimerId = SetTimer(NULL, RND_TIMER, 3456, &RandomTimerProc);
EndTimerId = SetTimer(NULL, END_TIMER, 10000, &EndTimerProc);
MSG Msg;
while (GetMessage(&Msg, NULL, 0, 0))
{
DispatchMessage(&Msg);
}
return 0;
}
|