|
第一步:创建基于对话框的工程
然后在RC文件选择对话框,并对其进行如下界面的布局
接着在控件属性那给控件修改名称和ID,并且会在resources.h文件自动生成相应的ID值。
给开始按钮添加,响应事件:右键开始按钮 选择属性对话框 在clicked中新建一个click 自动会在CPP中生成相应的函数
所有都设置完,输入如下代码:
void CMFC小程序Dlg::OnRButtonDown(UINT nFlags, CPoint point)
{undefined
// TODO: Add your message handler code here and/or call default
CDialog::OnRButtonDown(nFlags, point);
Total++;
CDialog::OnLButtonDown(nFlags, point);
CTime endtime = CTime::GetCurrentTime();
CTimeSpan timespan = endtime - begintime;
float seconds = (float)(timespan.GetSeconds());
m_edit1 = Total / seconds * 60;
if(m_edit1 < 200)
{undefined
m_edit2 = L"新手入门";
}
else{undefined
m_edit2 = L"鼠标达人";
}
UpdateData(FALSE);
}
void CMFC小程序Dlg::OnLButtonDown(UINT nFlags, CPoint point)
{undefined
// TODO: Add your message handler code here and/or call default
Total++;
CDialog::OnLButtonDown(nFlags, point);
CTime endtime = CTime::GetCurrentTime();
CTimeSpan timespan = endtime - begintime;
float seconds = (float)(timespan.GetSeconds());
m_edit1 = Total / seconds * 60;
if(m_edit1 < 200)
{undefined
m_edit2 = L"新手入门";
}
else{undefined
m_edit2 = L"鼠标达人";
}
UpdateData(FALSE);
}
void CMFC小程序Dlg::OnBnClickedButton()
{undefined
begintime = CTime::GetCurrentTime();
Total = 0;
}
|
|