找回密码
 加入
搜索
查看: 1053|回复: 3

GUISetOnEvent的问题

[复制链接]
发表于 2009-11-14 10:03:10 | 显示全部楼层 |阅读模式
本帖最后由 newx 于 2009-11-19 03:46 编辑

GUISetOnEvent怎么就不灵了呢?
找不出原因,可能我搞的头混了,点按钮后不起作用了,Why?
#include <GUIConstantsEx.au3>

Opt("GUIOnEventMode", 1)

Global $Form1, $SB, $DownARB, $EB

$Form1 = GUICreate("Test", 605, 351)
GUISetOnEvent ( $GUI_EVENT_CLOSE, "Event" )

$SB = GUICtrlCreateButton("扫描", 240, 312, 105, 25)
GUISetOnEvent ( $SB, "Event" )

$DownARB = GUICtrlCreateButton("下载", 360, 312, 121, 25)
GUISetOnEvent ( $DownARB, "Event" )

$EB = GUICtrlCreateButton("退 出", 496, 312, 97, 25)
GUISetOnEvent ( $EB, "Event" )

GUISetState(@SW_SHOW)

    While 1
        Sleep(10)
    WEnd

Func Event()
   Switch @GUI_CtrlId
      Case $EB
         Exit
      Case $GUI_EVENT_CLOSE
         Exit
      Case $SB
         SysSearch()
      Case $DownARB
         nDownload()
   EndSwitch
EndFunc

Func nDownload()
   ;下载
EndFunc

Func SysSearch()
   ;扫描
EndFunc
发表于 2009-11-14 10:17:13 | 显示全部楼层
GUICtrlSetOnEvent ...
#include <GUIConstantsEx.au3>

Opt("GUIOnEventMode", 1)
Global $Form1, $SB, $DownARB, $EB
$Form1 = GUICreate("Test", 605, 351)
GUISetOnEvent($GUI_EVENT_CLOSE, "Event")
$SB = GUICtrlCreateButton("扫描", 240, 312, 105, 25)
GUICtrlSetOnEvent($SB, "Event")
$DownARB = GUICtrlCreateButton("下载", 360, 312, 121, 25)
GUICtrlSetOnEvent($DownARB, "Event")
$EB = GUICtrlCreateButton("退 出", 496, 312, 97, 25)
GUICtrlSetOnEvent($EB, "Event")
GUISetState(@SW_SHOW)

While 1
        Sleep(10)
WEnd

Func Event()
        Switch @GUI_CtrlId
                Case $EB
                        Exit
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $SB
                        SysSearch()
                Case $DownARB
                        nDownload()
        EndSwitch
EndFunc   ;==>Event

Func nDownload()
        MsgBox(0, 0, '下载')
EndFunc   ;==>nDownload

Func SysSearch()
        MsgBox(0, 0, '扫描')
EndFunc   ;==>SysSearch
 楼主| 发表于 2009-11-14 10:22:39 | 显示全部楼层
GUICtrlSetOnEvent 和 GUISetOnEvent
晕,谢谢二楼
头大了头大了……
发表于 2009-11-14 10:46:15 | 显示全部楼层
控件和窗体事件设置函数不一样的
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-18 14:14 , Processed in 0.077409 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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