Home > Software engineering >  The use of the novice consult WaitableTimer!
The use of the novice consult WaitableTimer!

Time:11-10

//in front of some painting fan code
HANDLE hTimer;
Void CALLBACK TimerAPCProc (LPVOID lpArg, dwords DWL DWORD dw2)
{
LpArg CWINDMILLDlg * timer=(CWINDMILLDlg *);
The timer - & gt; The SendMessage (WM_TIMER, 0, 0);

}


Void CWINDMILLDlg: : OnBnClickedStart ()
{

CRect rect1;
Rect1. Left=500;
Rect1. Top=200;
Rect1. Right=250;
Rect1. Bottom=200;

The UpdateData (true);


LARGE_INTEGER li;
Const int nTimerUnitsPerSecond=10000000;
Li. QuadPart=- (1 * nTimerUnitsPerSecond);

HTimer=CreateWaitableTimer (NULL, FALSE, NULL);
The InvalidateRect (& amp; Rect1);
SetWaitableTimer (hTimer, & amp; Li, 0, TimerAPCProc, NULL, FALSE);


}


Void CWINDMILLDlg: : OnTimer (UINT_PTR nIDEvent)
{
//TODO: add the message handler code and/or invoke the default
CRect rect1;

Rect1. Left=500;
Rect1. Top=200;
Rect1. Right=250;
Rect1. Bottom=200;

The InvalidateRect (& amp; Rect1);

The UpdateData (TRUE);

CDialogEx: : OnTimer (nIDEvent);
}
I this application is mainly a fan rotation, and then I will not be able to automatically turn now, click the rotation, I don't know where the problem is that, the multi-media timer feeling is similar to the idea, and succeeded,, but I couldn't think out, SOB to teach
  • Related