anythinging 发表于 2023-10-23 16:04:48

关于GUICtrlCreateMenu的响应

请教各位朋友,关于GUICtrlCreateMenu,有没有办法实现点退出就可以直接响应,就是不用点出下拉菜单。
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>

Example()
Func Example()
    GUICreate("菜单控件 GUI", 300, 200)

    Local $idFilemenu = GUICtrlCreateMenu("文件")
    Local $idFileitem = GUICtrlCreateMenuItem("打开", $idFilemenu)
    GUICtrlSetState(-1, $GUI_DEFBUTTON)
    Local $idHelpmenu = GUICtrlCreateMenu("退出")

    GUISetState(@SW_SHOW)

    While 1
      Switch GUIGetMsg()
                        Case $idFileitem
                              MsgBox(0,'','test1',1)
                        Case $idHelpmenu
                              MsgBox(0,'','test2',1)

                        Case $GUI_EVENT_CLOSE
                ExitLoop
      EndSwitch
    WEnd
    GUIDelete()
EndFunc

anythinging 发表于 2023-10-23 16:09:03

我现在都是通过GUICtrlCreateMenuItem来实现响应,能否直接GUICtrlCreateMenu实现响应?

holley 发表于 2023-10-26 11:53:55

anythinging 发表于 2023-10-23 16:09
我现在都是通过GUICtrlCreateMenuItem来实现响应,能否直接GUICtrlCreateMenu实现响应?

机器人回复:AutoIt 无法直接为主菜单项设置点击事件。这是因为 AutoIt 中的主菜单项仅用作容器,而不能为其设置事件。
页: [1]
查看完整版本: 关于GUICtrlCreateMenu的响应