More actions
imported>Unknown No edit summary |
(Repair batch-0001 pages from live compare) |
||
| Line 83: | Line 83: | ||
---- | ---- | ||
[[5인용C++스터디]] | [[5인용C++스터디]] | ||
Latest revision as of 23:55, 26 March 2026
멀티미디어 타이머 사용하기.
첫번째
Project -> Settings -> Link -> Object/library modules: 에 winmm.lib 추가
두번째
StdAfx.h 에서...
. . . #include <afxwin.h> // MFC core and standard components #include <afxext.h> // MFC extensions #include <afxdisp.h> // MFC Automation classes #include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls #ifndef _AFX_NO_AFXCMN_SUPPORT #include <afxcmn.h> // MFC support for Windows Common Controls #endif // _AFX_NO_AFXCMN_SUPPORT #include <mmsystem.h> //Template:AFX INSERT LOCATION // Microsoft Visual C++ will insert additional declarations immediately before the previous line. . . .
세번째
타이머 프로시져 추가
void CALLBACK TimerProc(UINT uID, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2)
{
CMMTimerView *pView = (CMMTimerView*)dwUser;
pView->PostMessage(WM_USER);
}
네번째
타이머 설정 및 해제부분 추가
int CMMTimerView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
m_TimerID = timeSetEvent(1, 0, TimerProc, (DWORD)this, TIME_PERIODIC);
return 0;
}
void CMMTimerView::OnDestroy()
{
CView::OnDestroy();
timeKillEvent(m_TimerID);
}
다섯번째
WM_USER 메시지 처리 부분 추가
BEGIN_MESSAGE_MAP(CMMTimerView, CView)
//{{AFX_MSG_MAP(CMMTimerView)
.
.
//}}AFX_MSG_MAP
.
.
ON_MESSAGE(WM_USER, OnMMTimer)
END_MESSAGE_MAP()
class CMMTimerView : public CView
{
.
.
.
// Generated message map functions
protected:
//{{AFX_MSG(CMMTimerView)
.
.
//}}AFX_MSG
afx_msg LRESULT OnMMTimer(WPARAM wParam, LPARAM lParam);
DECLARE_MESSAGE_MAP()
};
LRESULT CMMTimerView::OnMMTimer(WPARAM wParam, LPARAM lParam)
{
.
.
.
return 0;
}