Home > Software engineering >  The dialog box class, how to start a timer
The dialog box class, how to start a timer

Time:04-18

Want to achieve every once in a while will trigger a function, during the program does not Sleep

How to implement?

CodePudding user response:

The SetTimer
The SetTimer function creates a timer with The specified time - out value.

UINT SetTimer (
HWND HWND ,//handle of the window for the timer messages
UINT nIDEvent,//timer identifier
UINT uElapse,//the time - out value
TIMERPROC lpTimerFunc//address of the timer procedure
);

CodePudding user response:

SetTimer has a callback function, need not be HWND

CodePudding user response:

Using the Timer the Queues

CodePudding user response:

The callback function address how according to the function name for?

How to set a function to the callback function

CodePudding user response:

reference 4 floor pc12138cwp response:
address how the callback function according to the function name for?

How to set a function to the callback function
the fourth parameter directly fill the function name (without parentheses), and casts

CodePudding user response:

reference 4 floor pc12138cwp response:
address how the callback function according to the function name for?

How to set a function to the callback function

 VOID CALLBACK MyTimerProc (
_In_HWND HWND,
_In_UINT uMsg,
_In_UINT_PTR idEvent,
_In_DWORD dwTime
)
{
//...
}



: : SetTimer (NULL, IDT_MYTIMER, 1000/* interval, milliseconds */, TIMERPROC MyTimerProc)

CodePudding user response:

reference 4 floor pc12138cwp response:
address how the callback function according to the function name for?

How to set a function to the callback function

Pay attention to the timer is every once in a while to run once, has been running, don't stop, stop KillTimer
  • Related