U E D R , A S I H C RSS

MFC Study_2001/MM Timer


1. MultiMedia Timer

미디 게 되다.

는 ZP 01 다.

는 ZP 01 강 다.


2. 기본 개념

  • OnTimer SetTimer 로 구되는 가 머는 다.
    게 메로 구동되기 때문 다른 메면 그 만
    게 된다고 다. 는 동 막대기를 막
    면 공게 느려는 것 다.(나만 그런가?--;)

  • MultiMedia Timer를 게 됩다. Devpia 본 바
    MultiMedia Timer는 드를 만든다. 그래든 말든
    .

2.1. 기본

미디 관련된 러가나, 머를 구는데 다.

! 그러나 그 다.

는 WINMM.LIB를

는 MMSYSTEM.H 를 루드 다.

  • 는법 :
    #include <mmsystem.h> 를

    Project(P) - Setting(S, ALT+F7) 러 Link Object/Library modules:란 winmm.lib를 다.

2.1.1. timeSetEvent

머를 발동다.

~cpp 
MMRESULT timeSetEvent(UINT uDelay, UINT uResolution, LPTIMECALLBACK lpTimeProc, DWORD_PTR dwUser, UINT fuEvent);

  • MMRESULT 가 리다. NULL다.
  • uDelay : 머가 다. 단는 ms다.
  • uResolution : 대개 0 다만... 같다고 다.
  • lpTimeProc : CALLBACK 다.
  • dwUser : CALLBACK 다.
  • fuEvent : 머가 되는 방법 다.
    • TIME_ONESHOT : CALLBACK 다.
    • TIME_PERIODIC : uDelay 날 때다 CALLBACK다.

2.1.2. TimeProc

머로 러내 되는

~cpp 
void CALLBACK TimeProc(UINT uID, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2)

  • uID :
  • dwUser : timeSetEvent dwUser값 다.
  • 나머 두 변 다.
  • 된다. 굳 다면 static 다.

2.1.3. timeKillEvent

끝난 머를 는 부다.

~cpp 
MMRESULT timeKillEvent(UINT uTimerID);

  • uTimerID 다.

기본 다.

2.2.

CALLBACK

~cpp 
m_TimerID=timeSetEvent(20,1,&TimerProc,(DWORD)this,TIME_PERIODIC);
  • 머를 는 부다.
  • m_TimerID는 UINT 다.

~cpp 
void CALLBACK TimerProc(UINT uiID,UINT uiMsg,DWORD dwUser,DWORD dw1,DWORD dw2)
      {
             CAlcaDlg *pDlg=(CAlcaDlg*)AfxGetMainWnd();

	    pDlg->SendMessage(WM_MYMSG,0,0);
      }
  • 다. 는 복 는게 다고 다.

    그래로 날려 봤다. 그런데 못느끼겠더군..--;

    면 고 길...

~cpp 
CAlcaDlg *pDlg = (CAlcaDlg*)AfxGetMainWnd();
        // 메  
timeKillEvent(pDlg->m_TimerID);
        // 

CALLBACK

timeproc는 static 다.

  • CALLBACK 될 경는 static다.

~cpp 
m_nTimerID = timeSetEvent(5, 0, (LPTIMECALLBACK)timeproc, (DWORD)this, TIME_PERIODIC);
  • m_nTimerID는 UINT 다. 다.
  • 5는 머가 다. 는 ms(1/1000)다.
  • this는 다. 내부 다.

~cpp 
void CALLBACK CMyDlg::timeproc(UINT uID, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2){
 CMyDlg *pDlg = (CMyDlg *)dwUser;
 pDlg->......
dwUser는 timeSetEvent this값 pDlg 다.
pDlg를 모든 메 다.

~cpp 
timeKillEvnet(m_nTimerID);
setTimerEvent때 머를 다.

2.3.

  • CALLBACK . (in MSDN)

    - Applications should not call any system-defined functions from inside a callback function, except for PostMessage, timeGetSystemTime, timeGetTime, timeSetEvent, timeKillEvent, midiOutShortMsg, midiOutLongMsg, and OutputDebugString.

    - 내부로부 고는 를 부를 다. : PostMessage, timeGetSystemTime, timeGetTime, timeSetEvent, timeKillEvent, midiOutShortMsg, midiOutLongMsg, and OutputDebugString.

    Callback 부르면 다.
  • KB문 Q130866 다.
    CALLBACK 내부 는 Invalidte()나 user 메를 만들 날려면 됩다.


~cpp 
void CALLBACK EXPORT CTmrprocView::TimerProc(HWND hwnd, UINT msg, UINT idTimer, DWORD dwTime)
{
    CTmrprocView * pThis;
    
    if (m_thisList.Lookup(idTimer, (LPVOID &) pThis))
    {
        ASSERT(pThis->GetSafeHwnd());
        
        CDC* pDC = pThis->GetDC();
        
        wsprintf((LPSTR) pThis->m_strOutput, "CTmrprocView::TimerProc() Called. Count = %ld", ++pThis->m_cCount);
        pThis->Invalidate(TRUE);
    }
}


Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:23:41
Processing time 0.0204 sec