在程序中初次使用MMTimer,但是不成功,不太明白遇到的问题,请帮忙指点一下:我的代码如下:timersdlg.h文件CTimerDlg类定义中加入了:void MMTimerHandler(UINT nIDEvent);
static void CALLBACK TimerFunction(UINT wTimerID, UINT msg, DWORD dwUser, DWORD dw1, DWORD dw2); .cpp文件中加入了:static void CTimersDlg::OnButtonBegin()
{
// Set resolution to the minimum supported by the system
TIMECAPS tc;
timeGetDevCaps(&tc, sizeof(TIMECAPS));
DWORD resolution = min(max(tc.wPeriodMin, 0), tc.wPeriodMax);
timeBeginPeriod(resolution); // create the timer
m_idEvent = timeSetEvent(
m_elTime,
resolution,
TimerFunction,
(DWORD)this,
TIME_PERIODIC);
}
void CTimersDlg::OnButtonStop()
{
// destroy the timer
timeKillEvent(m_idEvent);
// reset the timer
timeEndPeriod (m_elTime);}void CTimersDlg::MMTimerHandler(UINT nIDEvent) // called every elTime milliseconds
{
myTimeProc();
}void CALLBACK TimerFunction(UINT wTimerID, UINT msg,
DWORD dwUser, DWORD dw1, DWORD dw2)
{
// This is used only to call MMTimerHandler
// Typically, this function is static member of CTimersDlg
CTimersDlg* obj = (CTimersDlg*) dwUser;
obj->MMTimerHandler(wTimerID);
} 但是编译时提示错误:error LNK2001: unresolved external symbol __imp__timeSetEvent@20
CTimersDlg.obj : error LNK2001: unresolved external symbol "public: static void __stdcall CTimersDlg::TimerFunction(unsigned int,unsigned int,unsigned long,unsigned long,unsigned long)" (?TimerFunction@CTimersDlg@@SGXIIK
KK@Z)
CTimersDlg.obj : error LNK2001: unresolved external symbol __imp__timeBeginPeriod@4
CTimersDlg.obj : error LNK2001: unresolved external symbol __imp__timeGetDevCaps@8
CTimersDlg.obj : error LNK2001: unresolved external symbol __imp__timeKillEvent@4
Debug/CTimersDlg.exe : fatal error LNK1120: 5 unresolved externals
Error executing link.exe.到底该怎么使用啊?哪位能帮帮我啊?多谢了
static void CALLBACK TimerFunction(UINT wTimerID, UINT msg, DWORD dwUser, DWORD dw1, DWORD dw2); .cpp文件中加入了:static void CTimersDlg::OnButtonBegin()
{
// Set resolution to the minimum supported by the system
TIMECAPS tc;
timeGetDevCaps(&tc, sizeof(TIMECAPS));
DWORD resolution = min(max(tc.wPeriodMin, 0), tc.wPeriodMax);
timeBeginPeriod(resolution); // create the timer
m_idEvent = timeSetEvent(
m_elTime,
resolution,
TimerFunction,
(DWORD)this,
TIME_PERIODIC);
}
void CTimersDlg::OnButtonStop()
{
// destroy the timer
timeKillEvent(m_idEvent);
// reset the timer
timeEndPeriod (m_elTime);}void CTimersDlg::MMTimerHandler(UINT nIDEvent) // called every elTime milliseconds
{
myTimeProc();
}void CALLBACK TimerFunction(UINT wTimerID, UINT msg,
DWORD dwUser, DWORD dw1, DWORD dw2)
{
// This is used only to call MMTimerHandler
// Typically, this function is static member of CTimersDlg
CTimersDlg* obj = (CTimersDlg*) dwUser;
obj->MMTimerHandler(wTimerID);
} 但是编译时提示错误:error LNK2001: unresolved external symbol __imp__timeSetEvent@20
CTimersDlg.obj : error LNK2001: unresolved external symbol "public: static void __stdcall CTimersDlg::TimerFunction(unsigned int,unsigned int,unsigned long,unsigned long,unsigned long)" (?TimerFunction@CTimersDlg@@SGXIIK
KK@Z)
CTimersDlg.obj : error LNK2001: unresolved external symbol __imp__timeBeginPeriod@4
CTimersDlg.obj : error LNK2001: unresolved external symbol __imp__timeGetDevCaps@8
CTimersDlg.obj : error LNK2001: unresolved external symbol __imp__timeKillEvent@4
Debug/CTimersDlg.exe : fatal error LNK1120: 5 unresolved externals
Error executing link.exe.到底该怎么使用啊?哪位能帮帮我啊?多谢了
解决方案 »
- vc中的IF语句判断两个数组
- 关于socket的简单问题!
- 当internal heap limit(Zm)增加至1400时,Zm无法再增大,这时怎么办?
- CString 和Unicode 的问题
- 请问高手, a->a1() 这个表示什么意思?
- 100分向高手求助:sql server2000中文版中将汉字作为一个字符,而vc中一个汉字占用两个字节。。。
- 求教一个在windows的任务栏生成小图标的源码,例如窗口最小化后就只有一个小图标在任务栏,感谢!
- 一个关于打开文件另存文件数据的问题,各位大虾help!!!!!!!!!
- 关于设置鼠标位置的问题.
- 为什么能预缆的位图却打印不出来?
- 问:程序运行的时候谁调用OnDraw()函数(解答越详细越好)?
- 为什么我在对话框里LOADICON会有错????
DWORD dwUser, DWORD dw1, DWORD dw2)
{
// This is used only to call MMTimerHandler
// Typically, this function is static member of CTimersDlg
CTimersDlg* obj = (CTimersDlg*) dwUser;
obj->MMTimerHandler(wTimerID);
}你不会用向导吗?
另外,如上所说,加一个链接库:winmm.lib。
另外static void CTimersDlg::OnButtonBegin()什么意思?