TC官方合作论坛

 找回密码
 立即注册
查看: 1082|回复: 0

[源码分享] 时间计时控制小源代码一枚

[复制链接]
发表于 2014-10-12 01:41:00 | 显示全部楼层 |阅读模式

马上加入TC

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
  1. namespace __Timer
  2. //默认空间
  3. var flag = false,tHandle
  4. var second=0,minute=0,hour=0

  5. //开始按钮_点击操作
  6. function start_click()
  7.    
  8. endfunction

  9. //退出按钮_点击操作
  10. function exit_click()
  11.     if(thread.closethread(tHandle))
  12.         tHandle  = 0
  13.         help.exit()
  14.     else
  15.         if(flag == true)
  16.             help.messagebox("线程关闭错误")
  17.             help.exit()
  18.         else
  19.             help.exit()
  20.         endif
  21.         
  22.     endif
  23. endfunction


  24. function TimeThread_Proc()
  25.     //秒分时
  26.    
  27.     var second_str ="00",minute_str="00",hour_str="00"
  28.     while(flag)
  29.         edit.settext("编辑框_内容",hour_str & ":" &minute_str & ":" &second_str)
  30.         help.sleep(1000)
  31.         second++
  32.         if(second == 60)
  33.             second = 0
  34.             minute = minute + 1
  35.         endif
  36.         
  37.         if(minute == 60)
  38.             minute = 0
  39.             hour = hour + 1
  40.         endif
  41.         
  42.         second_str = type.cstring(second)
  43.         minute_str = type.cstring(minute)
  44.         hour_str = type.cstring(hour)
  45.         if(str.strleng(second_str) == 1)//个位状态
  46.             second_str ="0"&second_str
  47.         endif
  48.         if(str.strleng(minute_str) == 1)//个位状态
  49.             minute_str = "0"&minute_str
  50.         endif
  51.         if(str.strleng(hour_str) == 1)//个位状态
  52.             hour_str = "0"&hour_str
  53.         endif
  54.         
  55.     endwhile
  56.     //
  57. endfunction



  58. function StopTime_click()
  59.     //这里添加你要执行的代码
  60.    
  61.     if(tHandle>0)
  62.         var state
  63.         
  64.         state=button.gettext("StopTime")
  65.         if(state == "停止计时")
  66.             //flag =false
  67.             thread.suspendthread(tHandle)
  68.             button.settext("StopTime","继续计时")
  69.         endif
  70.         
  71.         if (state == "继续计时")
  72.             //flag = true
  73.             thread.resumethread(tHandle)
  74.             button.settext("StopTime","停止计时")
  75.         endif
  76.         
  77.     else
  78.         help.messagebox("没有找到句柄,你还没有开启线程")
  79.     endif
  80.    
  81. endfunction


  82. function StartTime_click()
  83.     //这里添加你要执行的代码
  84.     if(flag == true)
  85.         help.messagebox("已开启计时,请不要重复开启!")
  86.     else
  87.         flag = true
  88.         tHandle = thread.beginthread("__Timer.TimeThread_Proc","")   
  89.     endif
  90.    
  91. endfunction

  92. endnamespace
  93. //空间结束
复制代码


学习一进一出哪里好?官方学院找EZ.

大家好,才是真的好
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条

关闭

小黑屋|TC官方合作论坛 (苏ICP备18045623号)

GMT+8, 2024-5-14 08:30 , Processed in 0.034385 second(s), 22 queries .

Powered by 海安简单软件服务部

© 2008-2019 版权所有 保留所有权利

快速回复 返回顶部 返回列表