请求高手解决一个运行中的问题
本帖最后由 sunny617 于 2009-7-23 12:50 编辑如题:
今天看了一天坛子里有关暂停程序的贴子
发现都是关于热键启动执行的
我想知道。。。怎么样在程序运行前做一个运行开关呢,,然后当点击运行时“运行”变面“暂停”
关键在于暂停又怎么反回开始运行呢??
求教;(下面是简单的说)
-----------------------------------------------------
#include <GuiConstantsEx.au3>
Global $mune1, $mune2, $mune3,$mune4,$mune5,$BS_FLAT, $BS_CENTER
;GUI
$Win=GUICreate("my test ",400,400,700,350)
GUISetIcon(@SystemDir &"",0)
$mune1 = GUICtrlCreateMenu("文件[&F]")
$next_mune1= GUICtrlCreateMenuItem("退出程序[&X]",$mune1)
$Button_tab0=GUICtrlCreateButton("Network Settings",260,290,Default,Default,$BS_FLAT & $BS_CENTER)
GUICtrlSetTip(-1,"进入目标设备配置")
$Button_color=GUICtrlSetColor($Button_tab0,0x000080)
$win_Childw = GUICreate("network settings Top mesh",400,200,700,450)
GUISwitch($Win)
$Bs_motion =GUICtrlCreateButton("运行",20,240,70,Default)
$Tab0color=GUICtrlSetColor($Bs_motion,0xC40000)
GUISetState(@SW_SHOW)
#EndRegion ### START Koda GUI section ###Win========================================
While 1
$nmsg = GUIGetMsg()
While 1
Select
Case $nmsg= $GUI_EVENT_CLOSE
If MsgBox(1,"警告","你真的要退出吗?")=1 Then ;当选为1时msgbox反回控件信息
ExitLoop
EndIf
Case $nmsg= $next_mune1
ExitLoop
Case $nmsg=$Button_tab0
GUISwitch($win_Childw)
GUISetState(@SW_SHOW)
;GUISetState(@SW_DISABLE,$win) 禁止访问主窗口
EndSelect
WEnd
--------------------------------------------------------
我如何在如While 1等程序开始运行时做一个$Bs_motion控制的开关
以便随时暂停和运行呢?
求高手:face (7): 不想要传送门:face (18): 1. Func _PAUSE()
2. If $PAUSE = 1 Then
3. GUICtrlSetData($Button1, "暂停")
4. Else
5. GUICtrlSetData($Button1, "开始")
6. EndIf
7. $PAUSE = Not $PAUSE
8. EndFunc
为什么我用这个不行???
:face (3):没人理???真的没法吗? IF GUICtrlRead ($Bs_motion) = "暂停" Then
GUICtrlSetData($Bs_motion, "运行")
Else
GUICtrlSetData($Bs_motion, "暂停")
EndIf
不是很理解你的意思.. 本帖最后由 afan 于 2009-7-23 14:58 编辑
我是新手,写了个小例子,不知道能不能帮到你~
#include <GUIConstantsEx.au3>
Opt("GUIOnEventMode", 1)
Dim $tj = 0
$Form1 = GUICreate("test", 150, 70)
$Button1 = GUICtrlCreateButton("", 20, 10, 110, 25)
GUICtrlSetData(-1, '运行')
GUICtrlSetOnEvent(-1, "gui")
$Label1 = GUICtrlCreateLabel("运行中 ", 10, 45, 130, 15)
GUICtrlSetOnEvent(-1, "gui")
GUICtrlSetState(-1, $Gui_Hide)
GUISetOnEvent($GUI_EVENT_CLOSE, "gui")
GUISetState()
While 1
If $tj = 1 Then
MsgBox(0, "", "运行中")
Sleep(5000)
EndIf
WEnd
Exit
Func gui()
Switch @GUI_CtrlId
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$br = GUICtrlRead($Button1)
if $br = '运行' then
GUICtrlSetData($Button1, '停止')
AdlibEnable("xs", 500)
GUICtrlSetData($Label1, "运行中 ")
GUICtrlSetState($Label1, $Gui_Show)
$tj = 1
Elseif $br = '已暂停,点击继续' then
GUICtrlSetData($Button1, '停止')
AdlibEnable("xs", 500)
$tj = 1
Elseif $br = '停止' then
GUICtrlSetData($Button1, '运行')
AdlibDisable()
GUICtrlSetState($Label1, $Gui_Hide)
$tj = 0
endif
Case $Label1
$br = GUICtrlRead($Button1)
if $br = '停止' then
AdlibDisable()
GUICtrlSetData($Button1, '已暂停,点击继续')
$tj = 0
Elseif $br = '已暂停,点击继续' then
GUICtrlSetData($Button1, '停止')
AdlibEnable("xs", 500)
$tj = 1
endif
EndSwitch
EndFunc ;==>gui
Func xs()
$lb = GUICtrlRead($Label1)
if $lb = "运行中 |||||||||||||" then
GUICtrlSetData($Label1, "运行中 ")
else
GUICtrlSetData($Label1, $lb & "|")
endif
EndFunc ;==>xs
点击按钮可进行“运行”“停止”
点击进度条可“暂停”“继续” 修改了下,增加点击进度条可“暂停”“继续”
页:
[1]