au3打开子窗口、父子窗口
#include <GUIConstants.au3>
$WinMain = GUICreate("主窗口", 450, 300) ;创建主窗口
$Button1 = GUICtrlCreateButton("1", 0, 0, 113, 49, 0)
$Button2 = GUICtrlCreateButton("显示子窗口", 216, 0, 105, 49, 0);创建主窗口中按钮二
;$WinSub = GUICreate("子窗口", 220, 60) ;创建子窗口
;$Button21 = GUICtrlCreateButton("确认", 0, 0, 100, 50)
; $Button22 = GUICtrlCreateButton("取消BUTTON22", 110, 0, 100, 50);创建子窗口中按钮二
$WinSub = GUICreate("闹钟提醒1111", 500, 200, 700, 100, -1, -1)
$Label1 = GUICtrlCreateLabel("闹钟内容:", 20, 10, 370, 50)
$Label2 = GUICtrlCreateLabel("2015/12/12 11:11:11", 100, 20, 370, 50)
$button21 = GUICtrlCreateButton("确定", 100, 110, 80, 25)
$button22 = GUICtrlCreateButton("延后5分钟", 200, 110, 80, 25)
GUISwitch($WinMain) ;切换当前窗口到主窗口
GUISetState(@SW_SHOW) ;显示当前窗口
While 1
$nMsg = GUIGetMsg(1) ;捕获窗口消息
;~ 在这里,$nMsg是一个数组,相关说明:
;~ $nMsg[0] = 0 或 事件 ID 或 控件 ID
;~ $nMsg[1] = 产生事件的窗口句柄
;~ $nMsg[2] = 产生事件的控件句柄(若适用)
;~ $nMsg[3] = 鼠标指针的当前 X 坐标(相对于 GUI 窗口)
;~ $nMsg[4] = 鼠标指针的当前 Y 坐标(相对于 GUI 窗口)
Switch $nMsg[0] ;选择事件 ID 或 控件 ID
Case $GUI_EVENT_CLOSE ;如果点下的是$GUI_EVENT_CLOSE(关闭)
Switch $nMsg[1] ; 选择产生事件的窗口
Case $WinMain ; 如果是主窗口
Exit ; 退出
Case $WinSub ; 如果是子窗口
GUISwitch($WinSub) ; 切换当前窗口到子窗口
GUISetState(@SW_HIDE) ; 隐藏当前窗口
EndSwitch
Case $Button1
MsgBox(0, "你好", "你点了第一个按钮")
Case $Button2 ;如果点下的是主窗口中的按钮二
GUISwitch($WinSub) ; 切换当前窗口到子窗口
GUISetState(@SW_SHOW) ; 显示当前窗口
Case $Button21
MsgBox(0, "你好", "你点了子窗口第一个按钮")
Case $Button22 ;如果点下的是主窗口中的按钮二
GUISwitch($WinSub) ; 切换当前窗口到子窗口
GUISetState(@SW_HIDE) ; 隐藏当前窗口
EndSwitch
WEnd
au3以函数形式打开父子窗口
Local $sInput
_gui_main()
Func _gui_main()
Local $hGui_main, $msg
Local $bt_child, $bt_input
$hGui_main = GUICreate('main gui', 300, 150)
$bt_child = GUICtrlCreateButton('子窗口', 50, 50)
$bt_input = GUICtrlCreateButton('信息', 180, 50)
GUISetState()
While True
$msg = GUIGetMsg()
Switch $msg
Case -3 ;点击了关闭窗体
GUIDelete($hGui_main)
ExitLoop
Case $bt_child
GUISetState(@SW_DISABLE, $hGui_main)
_gui_child()
GUISetState(@SW_ENABLE, $hGui_main)
WinActivate($hGui_main)
Case $bt_input
MsgBox(0, 'info from child', $sInput, 0, $hGui_main)
EndSwitch
WEnd
EndFunc
Func _gui_child()
Local $hGui_child, $msg
Local $bt_back, $input
; $hGui_child = GUICreate('child gui', 300, 100)
$hGui_child = GUICreate("闹钟提醒1111", 500, 200, 700, 100, -1, -1)
;GUICtrlCreateLabel("闹钟内容:", 20, 10, 370, 50)
;GUICtrlCreateLabel("2015/12/12 11:11:11", 140, 80, 370, 50)
$bt_back = GUICtrlCreateButton("确定fanhui", 100, 110, 80, 25)
$button_later = GUICtrlCreateButton("延后5分钟", 200, 110, 80, 25)
$input = GUICtrlCreateInput('', 50, 25, 200, 17)
; $bt_back = GUICtrlCreateButton('返回', 130, 60)
GUISetState()
Do
$msg = GUIGetMsg()
Until $msg = -3 Or $msg = $bt_back
$sInput = GUICtrlRead($input)
GUIDelete($hGui_child)
EndFunc
最后编辑: admin 文档更新时间: 2021-03-16 21:55 作者:admin