High Precision multimedia clock Application

Source: Internet
Author: User
//////////////////////////////////////// ////// High-resolution timer // multimedia high-precision clock application class /////////////////////// /// // # include <mmsystem. h> # pragma comment (Lib, "winmm. lib ") Class invocation {typedef void (* timercallback) (DWORD); Private: DWORD m_dwuser; mmresult m_nidtimer; uint m_udelay; timercallback m_pfncallback; void killtimer () {If (callback! = NULL) {timekillevent (m_nidtimer); m_nidtimer = NULL;} public: chighresolutiontimer () {m_nidtimer = NULL; m_udelay = 0; m_pfncallback = 0;} virtual ~ Chighresolutiontimer () {killtimer ();} static void callback timeproc (uint uid, uint umsg, DWORD dwuser, DWORD dw1, DWORD dw2) {// dwuser contains PTR to timer objectchighresolutiontimer * ptimer = (chighresolutiontimer *) dwuser; // call user-specified callback and pass back user specified data (ptimer-> m_pfncallback) (ptimer-> m_dwuser);} bool createtimer (DWORD dwuser, uint udelay, timercallback lptimeproc) {SERT (dwuser); Assert (lptimeproc); m_dwuser = dwuser; m_pfncallback = lptimeproc; bool ret = false; killtimer (); delimiter = timesetevent (udelay, 0, timeproc, (DWORD) this, time_periodic | time_callback_function); If (m_nidtimer! = NULL) ret = true; Return (RET );}};

 
 
 
// Application. h chighresolutiontimer mm_timer; static void timercallback (DWORD dwuser); // application. CPP timer callback void cmy_timerdlg: timercallback (DWORD dwuser) {cmy_timerdlg * pthis = (cmy_timerdlg *) dwuser; // static Long Count = 0; cstring STR; Str. format ("% d", Count ++); pthis-> getdlgitem (idc_button1)-> setwindowtext (STR); BEEP (1000,1 );} // start the 2-millisecond timer void cmy_timerdlg: onbutton1 () {// todo: add your control notification handler code here // mm_timer.createtimer (DWORD) This, 2, timercallback );}

 

 
 

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.