#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
Opt('MustDeclareVars', 1)
Example()
Func Example()
Local $defaultstatus = "就绪", $status, $filemenu, $fileitem
Local $helpmenu, $saveitem, $infoitem, $exititem, $recentfilesmenu
Local $separator1, $viewmenu, $viewstatusitem, $okbutton, $cancelbutton
Local $statuslabel, $msg, $file
GUICreate("我的菜单窗口", 300, 200)
$filemenu = GUICtrlCreateMenu("文件(&F)")
$fileitem = GUICtrlCreateMenuItem("打开", $filemenu)
GUICtrlSetState(-1, $GUI_DEFBUTTON)
$helpmenu = GUICtrlCreateMenu("帮助")
$saveitem = GUICtrlCreateMenuItem("保存", $filemenu)
GUICtrlSetState(-1, $GUI_DISABLE)
$infoitem = GUICtrlCreateMenuItem("信息", $helpmenu)
$exititem = GUICtrlCreateMenuItem("退出", $filemenu)
$recentfilesmenu = GUICtrlCreateMenu("最近文件", $filemenu, 1)
$separator1 = GUICtrlCreateMenuItem("", $filemenu, 2) ; 创建分隔行
$viewmenu = GUICtrlCreateMenu("查看", -1, 1) ; 创建 "帮助" 的前项菜单
$viewstatusitem = GUICtrlCreateMenuItem("状态栏", $viewmenu)
GUICtrlSetState(-1, $GUI_CHECKED)
$okbutton = GUICtrlCreateButton("确定", 50, 130, 70, 20)
GUICtrlSetState(-1, $GUI_FOCUS)
$cancelbutton = GUICtrlCreateButton("删除", 180, 130, 70, 20)
$statuslabel = GUICtrlCreateLabel($defaultstatus, 0, 165, 300, 16, BitOR($SS_SIMPLE, $SS_SUNKEN))
GUISetState()
While 1
$msg = GUIGetMsg()
If $msg = $fileitem Then
$file = FileOpenDialog("选择文件...", @TempDir, "全部 (*.*)")
If @error <> 1 Then GUICtrlCreateMenuItem($file, $recentfilesmenu)
EndIf
If $msg = $viewstatusitem Then
If BitAND(GUICtrlRead($viewstatusitem), $GUI_CHECKED) = $GUI_CHECKED Then
GUICtrlSetState($viewstatusitem, $GUI_UNCHECKED)
GUICtrlSetState($statuslabel, $GUI_HIDE)
Else
GUICtrlSetState($viewstatusitem, $GUI_CHECKED)
GUICtrlSetState($statuslabel, $GUI_SHOW)
EndIf
EndIf
If $msg = $GUI_EVENT_CLOSE Or $msg = $cancelbutton Or $msg = $exititem Then ExitLoop
If $msg = $infoitem Then MsgBox(0, "信息", "只是测试...")
WEnd
GUIDelete()
EndFunc ;==>Example
|