![]() |
#2
oicq2014-05-31 13:33
回复 楼主 oicq
|

//开始记录鼠标位置
void CfileDlg::OnBnClickedButton1()
{
// TODO: 在此添加控件通知处理程序代码
MessageBox(L"开始记录用户鼠标位置");
m_bSig = true;
if(!file.Open(L"..\\lgz.bat",CFile::modeCreate|CFile::modeWrite,0))
{
MessageBox(L"打开文件失败");
return ;
}
}
//结束记录鼠标位置
void CfileDlg::OnBnClickedButton2()
{
// TODO: 在此添加控件通知处理程序代码
MessageBox(L"停止记录");
m_bSig = false;
file.Close();
}
//添加鼠标移动消息响应函数
void CfileDlg::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
if (m_bSig == true)
{
WCHAR buf[100] ={0};
wsprintf(buf,L"鼠标 x 坐标: %d ------- y 坐标:%d\r\n",point.x,point.y);
file.SeekToEnd();
file.WriteString(buf);
file.Flush();
}
CDialog::OnMouseMove(nFlags, point);
}
//对话框类添加的成员变量
public:
bool m_bSig; //是否开始记录鼠标
CStdioFile file;
N次试验 数据都写不到文件里去
void CfileDlg::OnBnClickedButton1()
{
// TODO: 在此添加控件通知处理程序代码
MessageBox(L"开始记录用户鼠标位置");
m_bSig = true;
if(!file.Open(L"..\\lgz.bat",CFile::modeCreate|CFile::modeWrite,0))
{
MessageBox(L"打开文件失败");
return ;
}
}
//结束记录鼠标位置
void CfileDlg::OnBnClickedButton2()
{
// TODO: 在此添加控件通知处理程序代码
MessageBox(L"停止记录");
m_bSig = false;
file.Close();
}
//添加鼠标移动消息响应函数
void CfileDlg::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
if (m_bSig == true)
{
WCHAR buf[100] ={0};
wsprintf(buf,L"鼠标 x 坐标: %d ------- y 坐标:%d\r\n",point.x,point.y);
file.SeekToEnd();
file.WriteString(buf);
file.Flush();
}
CDialog::OnMouseMove(nFlags, point);
}
//对话框类添加的成员变量
public:
bool m_bSig; //是否开始记录鼠标
CStdioFile file;
N次试验 数据都写不到文件里去
[ 本帖最后由 oicq 于 2014-5-30 02:30 编辑 ]