大大们帮帮忙,wince内timeSetEvent调用问题
编译的时候产生
error C2664: 'timeSetEvent' : cannot convert parameter 3 from 'void (__cdecl CCamera_AppDlg::* )(UINT,UINT,DWORD,DWORD,DWORD)' to 'LPTIMECALLBACK'
下面附相关代码
void CCamera_AppDlg::OnBnClickedBtnRecord()
{
UINT TimerID_1000ms;
TimerID_1000ms= timeSetEvent(1000,1,&CCamera_AppDlg::MyCallBack,0,TIME_PERIODIC);
}
void PASCAL CCamera_AppDlg::MyCallBack(UINT wTimerID, UINT msg,DWORD dwUser,DWORD dwl,DWORD dw2)
{。。。。}
在头文件里定义:
class CCamera_AppDlg : public CDialog
{......
......
public:
afx_msg void OnBnClickedBtnPreview();
afx_msg void OnBnClickedBtnSnap();
afx_msg void OnBnClickedBtnRecord();
void PASCAL MyCallBack(UINT,UINT,DWORD,DWORD,DWORD);
};
我怀疑是和在类里创造线程的时犯的错误类似。但是又不肯定。能不能请大大帮忙看看怎么解决,在此感激不尽。
PS:我把上面强制转换改成TimerID_1000ms= timeSetEvent(1000,1,(LPTIMECALLBACK)CCamera_AppDlg::MyCallBack,0,TIME_PERIODIC);
结果产生
error C2440: 'type cast' : cannot convert from 'overloaded-function' to 'LPTIMECALLBACK'
望各位大大给以提点,再次的感谢!
[解决办法]
class CCamera_AppDlg : public CDialog{......public: static void PASCAL MyCallBack(UINT,UINT,DWORD,DWORD,DWORD); void MyCallBack2(UINT,UINT,DWORD,DWORD);};void PASCAL CCamera_AppDlg::MyCallBack(UINT wTimerID, UINT msg,DWORD dwUser,DWORD dwl,DWORD dw2) { ((CCamera*)dwUser)->MyCallBack2(wTimerID, msg, dw1, dw2);}void CCamera_AppDlg::MyCallBack2(UINT wTimerID, UINT msg,DWORD dwl,DWORD dw2) { MySnap();}void CCamera_AppDlg::OnBnClickedBtnRecord(){TimerID_3000ms= timeSetEvent(500,1,MyCallBack,(DWORD)this,TIME_PERIODIC);}
[解决办法]