#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
Opt("TrayMenuMode",1) ; 默认菜单项目 (脚本暂停中/退出)(Script Paused/Exit) 将不会显示.
$settingsitem = TrayCreateItem("设置...")
TrayCreateItem("")
$aboutitem = TrayCreateItem("关于...")
TrayCreateItem("")
$exititem = TrayCreateItem("退出...")
TraySetState()
While 1
$msg = TrayGetMsg()
Select
Case $msg = 0
ContinueLoop
Case $msg = $settingsitem
;Msgbox(64,"提醒:","这是配置选项!")
Win1()
Case $msg = $aboutitem
;Msgbox(64,"提醒:","这是关于选项!")
Win2()
Case $msg = $exititem
;Msgbox(64,"提醒:","这是退出选项!")
ExitLoop
EndSelect
WEnd
Func Win1()
Local $gui1, $msg, $Group1, $Label1, $Label2, $Label3, $Input1, $Input2, $Input3, $Button_1, $Button_2
$gui1 = GUICreate("服务器IP设置", 290, 242, Default, default, BitOR($WS_CAPTION,$WS_POPUP,$WS_SYSMENU))
$Group1 = GUICtrlCreateGroup("设置服务器IP", 12, 12, 270, 182)
$Label1 = GUICtrlCreateLabel("服务器IP:", 30, 52, 65, 12)
$Label2 = GUICtrlCreateLabel("管理员账号:", 30, 97, 77, 12)
$Label3 = GUICtrlCreateLabel("管理员密码:", 30, 142, 77, 12)
$Input1 = GUICtrlCreateInput("", 112, 45, 150, 22)
$Input2 = GUICtrlCreateInput("", 112, 90, 150, 22)
$Input3 = GUICtrlCreateInput("", 112, 135, 150, 22)
$Button_1 = GUICtrlCreateButton("确定", 52, 206, 77)
$Button_2 = GUICtrlCreateButton("取消", 180, 206, 77)
GUISetState(@SW_SHOW)
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $Button_1
Msgbox(0,"","输入的IP地址格式不正确!")
Case $msg = $Button_2
Msgbox(0,"提醒:","你选择了退出!")
ExitLoop
EndSelect
WEnd
EndFunc
Func Win2()
Local $gui2, $msg, $pic, $Button_3, $Label1, $Label2, $Label3
$gui2 = GUICreate("网吧客户端", 404, 130, Default, default, BitOR($WS_CAPTION,$WS_POPUP,$WS_SYSMENU))
$pic = GUICtrlCreatePic("win2.gif", 0, 0, 404, 130)
GuiCtrlSetState(-1,$GUI_DISABLE)
$Button_3 = GUICtrlCreateButton("确定", 310, 10, 77)
GUICtrlSetBkColor(-1, 0xc0ffff)
GUISetState(@SW_SHOW)
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $Button_3
Msgbox(0,"提醒:","你选择了退出!")
ExitLoop
EndSelect
WEnd
EndFunc
Exit
托盘菜单执行后的子窗口独立运行时可以正常退出,但放到主程序一起再选退出窗口的时候就不能正常退出了。