找回密码
 加入
搜索
查看: 2686|回复: 9

[GUI管理] 提一个新手问题,求各位大大帮忙。

  [复制链接]
发表于 2015-1-20 18:44:17 | 显示全部楼层 |阅读模式
我现在做了一个窗口程序,有个运行按钮,我要点了运行按钮以后,按钮变成停止,然后执行循环代码。要怎么控制运行中点了停止,跳出循环停止程序并把按钮变成运行啊?没思路,求各位大大帮忙!!!万分感谢~
发表于 2015-1-20 18:48:17 | 显示全部楼层
在循环中取按钮消息,发现按了停止就退出循环
 楼主| 发表于 2015-1-20 19:49:23 | 显示全部楼层
具体要怎么操作啊,可以给个实例吗?
 楼主| 发表于 2015-1-21 20:05:53 | 显示全部楼层
怎么都没人理啊?
发表于 2015-1-21 22:22:41 | 显示全部楼层
以我的理解  要看你这个循环是干嘛的   不同环境  处理方式也不同的
 楼主| 发表于 2015-1-23 08:23:24 | 显示全部楼层
以我的理解  要看你这个循环是干嘛的   不同环境  处理方式也不同的
872777825 发表于 2015-1-21 22:22



    比分说呢?
发表于 2015-1-23 08:38:46 | 显示全部楼层
你把你做的程序代码发上来,然后大家帮你看..... 刚说没用.....
发表于 2015-1-30 08:30:21 | 显示全部楼层
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)

Dim $Start = 0
$Form1 = GUICreate("Form1", 151, 100, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")
$Button1 = GUICtrlCreateButton("运行", 24, 40, 97, 37)
GUICtrlSetOnEvent(-1, "_Button1")
$Label1 = GUICtrlCreateLabel("10000", 50, 20)
GUISetState(@SW_SHOW)

While 1
        Sleep(1000)
        If $Start = 1 Then GUICtrlSetData($Label1, GUICtrlRead($Label1) - 1)
WEnd


Func _exit()
        Exit
EndFunc   ;==>_exit

Func _Button1()
        If GUICtrlRead($Button1) = "运行" Then
                GUICtrlSetData($Button1, "停止")
                $Start = 1
        Else
                GUICtrlSetData($Button1, "运行")
                $Start = 0
        EndIf
EndFunc   ;==>_Button1
发表于 2015-1-30 08:47:19 | 显示全部楼层
唉,不就是个倒计时吗,论坛里有的是例子
发表于 2015-1-30 09:24:15 | 显示全部楼层
回复 1# vanlee


下面是按你说的过程实现
   
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 151, 100, 192, 124)
$Button1 = GUICtrlCreateButton("运行", 24, 40, 97, 37)
$Label1 = GUICtrlCreateLabel("10000", 50, 20)
GUISetState(@SW_SHOW)

While 1
        $nMsg = GUIGetMsg()
        Select
                Case $nMsg = $GUI_EVENT_CLOSE
                        Exit
                Case $nMsg = $Button1
                        GUICtrlSetData($Button1, "停止")
                        While GUIGetMsg() <> $Button1
                                GUICtrlSetData($Label1, GUICtrlRead($Label1) - 1)
                        WEnd
                        GUICtrlSetData($Button1, "运行")
        EndSelect
WEnd
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-29 22:05 , Processed in 0.078195 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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