设置处理控件点击的自定义函数.
GUICtrlSetOnEvent ( 控件ID, "函数" )
控件ID | 由 GUICtrlCreate... 函数返回的控件标识符. |
函数 | 被调用函数的名称. |
成功: | 返回 1. |
失败: | 返回 0, |
#include <GUIConstantsEx.au3>
Example()
Func Example()
Opt("GUICoordMode", 2)
Opt("GUIResizeMode", 1)
Opt("GUIOnEventMode", 1)
GUICreate("父窗
1")
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_MINIMIZE,
"SpecialEvents")
GUISetOnEvent($GUI_EVENT_RESTORE,
"SpecialEvents")
GUICtrlCreateButton("确定",
10, 30, 50)
GUICtrlSetOnEvent(-1, "OKPressed")
GUICtrlCreateButton("取消",
0, -1)
GUICtrlSetOnEvent(-1, "CancelPressed")
GUISetState(@SW_SHOW)
;
仅循环等待状态
While
1
Sleep(10)
WEnd
EndFunc ;==>Example
Func OKPressed()
MsgBox(0, "确定点击", "ID=" & @GUI_CtrlId & " 窗口句柄=" & @GUI_WinHandle &
" 控件句柄=" &
@GUI_CtrlHandle)
EndFunc ;==>OKPressed
Func CancelPressed()
MsgBox(0, "删除点击", "ID=" & @GUI_CtrlId & " 窗口句柄=" & @GUI_WinHandle &
" 控件句柄=" &
@GUI_CtrlHandle)
EndFunc ;==>CancelPressed
Func SpecialEvents()
Select
Case @GUI_CtrlId = $GUI_EVENT_CLOSE
MsgBox(0, "关闭点击", "ID=" & @GUI_CtrlId & " 窗口句柄=" & @GUI_WinHandle)
Exit
Case @GUI_CtrlId = $GUI_EVENT_MINIMIZE
MsgBox(0, "窗口最小化", "ID=" & @GUI_CtrlId & " 窗口句柄=" & @GUI_WinHandle)
Case @GUI_CtrlId = $GUI_EVENT_RESTORE
MsgBox(0, "窗口还原", "ID=" & @GUI_CtrlId & " 窗口句柄=" & @GUI_WinHandle)
EndSelect
EndFunc ;==>SpecialEvents
provider with jb51.net (unicode) |