|
马上加入TC
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
- namespace __Timer
- //默认空间
- var flag = false,tHandle
- var second=0,minute=0,hour=0
- //开始按钮_点击操作
- function start_click()
-
- endfunction
- //退出按钮_点击操作
- function exit_click()
- if(thread.closethread(tHandle))
- tHandle = 0
- help.exit()
- else
- if(flag == true)
- help.messagebox("线程关闭错误")
- help.exit()
- else
- help.exit()
- endif
-
- endif
- endfunction
- function TimeThread_Proc()
- //秒分时
-
- var second_str ="00",minute_str="00",hour_str="00"
- while(flag)
- edit.settext("编辑框_内容",hour_str & ":" &minute_str & ":" &second_str)
- help.sleep(1000)
- second++
- if(second == 60)
- second = 0
- minute = minute + 1
- endif
-
- if(minute == 60)
- minute = 0
- hour = hour + 1
- endif
-
- second_str = type.cstring(second)
- minute_str = type.cstring(minute)
- hour_str = type.cstring(hour)
- if(str.strleng(second_str) == 1)//个位状态
- second_str ="0"&second_str
- endif
- if(str.strleng(minute_str) == 1)//个位状态
- minute_str = "0"&minute_str
- endif
- if(str.strleng(hour_str) == 1)//个位状态
- hour_str = "0"&hour_str
- endif
-
- endwhile
- //
- endfunction
- function StopTime_click()
- //这里添加你要执行的代码
-
- if(tHandle>0)
- var state
-
- state=button.gettext("StopTime")
- if(state == "停止计时")
- //flag =false
- thread.suspendthread(tHandle)
- button.settext("StopTime","继续计时")
- endif
-
- if (state == "继续计时")
- //flag = true
- thread.resumethread(tHandle)
- button.settext("StopTime","停止计时")
- endif
-
- else
- help.messagebox("没有找到句柄,你还没有开启线程")
- endif
-
- endfunction
- function StartTime_click()
- //这里添加你要执行的代码
- if(flag == true)
- help.messagebox("已开启计时,请不要重复开启!")
- else
- flag = true
- tHandle = thread.beginthread("__Timer.TimeThread_Proc","")
- endif
-
- endfunction
- endnamespace
- //空间结束
复制代码
学习一进一出哪里好?官方学院找EZ.
大家好,才是真的好 |
|