Three methods for using a timer in Win32 API

Source: Internet
Author: User

1. settimer (hwnd, uint, uint, timerproc); the first parameter is set as the window handle to capture the scheduled message, and the second parameter is the timer ID, the third parameter is the timer length in milliseconds, and the last parameter is set to null. The callback function of the window can process the wm_timer message. In general, settimer is called when the window is created; the wm_timer response is added to the callback function. Then, when the window is destroyed, killtimer (hwnd, uint) is destroyed. The parameters are the window handle and timer ID.

 

2. settimer (hwnd, uint, uint, timerproc); the only difference from the first method is that the last parameter is not null, but a self-defined callback function. In this way, the wm_timer message will be retrieved and processed by the custom callback function. Killtimer (hwnd, uint) should also be used at the end );

 

3. idtimer = settimer (hwnd, uint, uint, timerproc); set the first parameter to null, and the second parameter to 0, the settings of the third and fourth parameters are the same as those of the second method. When a timer is created, a timer ID is returned and killtimer (null, idtimer) is called when the timer is destroyed ). This method is suitable for the frequent obfuscation of timer IDs.ProgramBecause its return value is used to manage the timer ID, instead of managing it by yourself.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.