找回密码  加入

AUTOIT CN

搜索
查看: 137|回复: 2

[AU3基础] 帮忙看个代码;为什么$idcose2不能使用$idcose后面必须加点字符

[复制链接]
发表于 2019-1-2 16:49:55 | 显示全部楼层 |阅读模式
#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>
#include <WindowsConstants.au3>

Opt("GUICoordMode", 1)
$hGUI = GUICreate("Menu", 400, 300)
Global Const $idButton = GUICtrlCreateButton("Test", 100, 100, 80, 40)
Global Const $idButton1 = GUICtrlCreateButton("Test-1", 300, 100, 80, 40)
Global Enum $idNew = 1000, $idOpen, $idClose2, $idExit;;;;;;;;;;;为什么$idcose2不能使用$idcose后面必须加点字符
Global Enum $idNew1 = 2000, $idOpen1, $idClose1, $idExit1
Global $hMenu
$hMenu = _GUICtrlMenu_CreatePopup()
Assign($idButton, $hMenu)
_GUICtrlMenu_InsertMenuItem($hMenu, 0, "新建文件", $idNew)
_GUICtrlMenu_InsertMenuItem($hMenu, 1, "", 0)
_GUICtrlMenu_InsertMenuItem($hMenu, 2, "打开文件", $idOpen)
_GUICtrlMenu_InsertMenuItem($hMenu, 3, "关闭文件", $idClose)
_GUICtrlMenu_InsertMenuItem($hMenu, 4, "", 0)
_GUICtrlMenu_InsertMenuItem($hMenu, 5, "退出", $idExit)


$hMenu1 = _GUICtrlMenu_CreatePopup()
Assign($idButton1, $hMenu1)
_GUICtrlMenu_InsertMenuItem($hMenu1, 0, "新建文件-button1", $idNew1)
_GUICtrlMenu_InsertMenuItem($hMenu1, 1, "", 0)
_GUICtrlMenu_InsertMenuItem($hMenu1, 2, "打开文件-button1", $idOpen1)
_GUICtrlMenu_InsertMenuItem($hMenu1, 3, "关闭文件-button1", $idClose1)
_GUICtrlMenu_InsertMenuItem($hMenu1, 4, "", 0)
_GUICtrlMenu_InsertMenuItem($hMenu1, 5, "退出-button1", $idExit1)

GUISetState()

GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

While 1
        $msg = GUIGetMsg()
        Switch $msg
                Case $GUI_EVENT_CLOSE
                        _GUICtrlMenu_DestroyMenu($hMenu)
                        GUIDelete()
                        Exit
                Case $idButton
                        ShowMenu($hGUI, $idButton)
                Case $idButton1
                        ShowMenu($hGUI, $idButton1)
        EndSwitch
WEnd

Func New()
        MsgBox(0, "信息", "新建文件")
EndFunc   ;==>New

Func Open()
        MsgBox(0, "信息", "打开")
EndFunc   ;==>Open

Func Close()
        MsgBox(0, "信息", "关闭")
EndFunc   ;==>Close

Func New1()
        MsgBox(0, "信息", "新建文件-1")
EndFunc   ;==>New1

Func Open1()
        MsgBox(0, "信息", "打开-1")
EndFunc   ;==>Open1

Func Close1()
        MsgBox(0, "信息", "关闭-1")
EndFunc   ;==>Close1

Func ShowMenu($hWnd, $id)
        Local $aButton = ControlGetPos("", "", $id)
        Local $x = $aButton[0]
        Local $y = $aButton[1] + $aButton[3]
        ClientToScreen($hGUI, $x, $y)
        _GUICtrlMenu_TrackPopupMenu(Eval($id), $hWnd, $x, $y)
        Return True
EndFunc   ;==>ShowMenu

Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
        Switch $iwParam
                Case $idNew
                        New()
                Case $idOpen
                        Open()
                Case $idClose
                        Close()
                Case $idExit
                        Exit
                Case $idNew1
                        New1()
                Case $idOpen1
                        Open1()
                Case $idClose1
                        Close1()
                Case $idExit1
                        Exit
        EndSwitch
EndFunc   ;==>WM_COMMAND

Func ClientToScreen($hWnd, ByRef $x, ByRef $y)
        Local $stPoint = DllStructCreate("int;int")
        DllStructSetData($stPoint, 1, $x)
        DllStructSetData($stPoint, 2, $y)
        DllCall("user32.dll", "int", "ClientToScreen", "hwnd", $hWnd, "ptr", DllStructGetPtr($stPoint))
        $x = DllStructGetData($stPoint, 1)
        $y = DllStructGetData($stPoint, 2)
        $stPoint = 0
EndFunc   ;==>ClientToScreen


发表于 2019-1-2 21:57:52 | 显示全部楼层
"D:\AU3调试\kk_lee69\RSA\範例\範例\basc.au3"(9,126) : 错误: $idClose 先前已声明为 'Const' 常量.
Global Enum $idNew = 1000, $idOpen,  $idExit, $idClose
发表于 2019-1-3 11:57:08 | 显示全部楼层
在包含的头文件 MsgBoxConstants.au3 中已被声明为常量
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|小黑屋|手机版|AUTOIT CN ( 鲁ICP备15028933号-3 )谷歌 百度

GMT+8, 2019-1-19 17:33 , Processed in 0.075264 second(s), 14 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表