辩论赛计时器

 时间:2024-10-29 04:47:39

1、打开VC++6.0,点击“新建”按钮,点击MFC Appwizard,在工程名称一栏输入想要的工程名称,在位置一栏输入想保存的路径,然后点击确定:

辩论赛计时器

2、打开对话框,在对话框上面添加控件如图所示:

辩论赛计时器

3、为计时器添加count count2,ksorzt,ksorzt2,minute,second,minute2,second2几个成员变量如图,并在构造函数中初始化:

辩论赛计时器辩论赛计时器

4、为对话框中的控件添加成员变量,如图所示:

辩论赛计时器

5、在:OnInitDialog()中添加代码:(改变编辑框中的字体)

辩论赛计时器

6、添加OnTimer()消息处理函数:并添加如下代码:void CJssDlg::OnTimer(UINT nIDEvent){ // TODO: Add your message handler code here and/or call defaultif(ksorzt) { if(count>0) { minute=count/60; second=count%60; CString str; str.Format("%d"":""%d",minute,second); m_strTime=str; UpdateData(false); --count; } else { m_strTime="时间到!"; UpdateData(false); } } if(ksorzt2) { if(count2>0) { minute2=count2/60; second2=count2%60; CString str2; str2.Format("%d"":""%d",minute2,second2); m_strTime2=str2; UpdateData(false); --count2; } else { m_strTime2="时间到!"; UpdateData(false); } } CDialog::OnTimer(nIDEvent);}

7、为正方和反方的开始和暂停按钮添加消息响应函数:void CJssDlg::OnButton1(){ // TODO: Add your control notification handler code here ksorzt=true; }void CJssDlg::OnButton2(){ // TODO: Add your control notification handler code here ksorzt=false; }void CJssDlg::OnButton3(){ // TODO: Add your control notification handler code here ksorzt2=true;}void CJssDlg::OnButton4(){ // TODO: Add your control notification handler code here ksorzt2=false;}其中button1和button2为正方的开始和暂停按钮,button3和button4为反方的开始和暂停按钮

8、为正方和反方的从新开始按钮添加消息相应函数:void CJssDlg::OnButton5(){ // TODO: Add your control notification handler code here ksorzt=false; count=600; m_strTime="10:0"; UpdateData(false); }void CJssDlg::OnButton6(){ // TODO: Add your control notification handler code here ksorzt2=false; count2=600; m_strTime2="10:0"; UpdateData(false);}

9、编译联接,运行。

  • WPS演示文稿怎样制作10秒倒计时效果
  • PPT中怎样制作自动倒计时效果
  • WPS 如何用PPT做倒计时?
  • 在PPT中插入一个计时器怎么做
  • ppt倒计时动画怎么做
  • 热门搜索
    车震什么意思 文献综述是什么 月经量少吃什么药 县长什么级别 重读闭音节是什么 心肌炎是什么病 山雨欲来风满楼什么意思 什么的花香 什么是社会公德 乔迁之喜送什么