找回密码
 加入
搜索
查看: 1854|回复: 2

[AU3基础] 右键菜单点击的结果都一样(已解决)

[复制链接]
发表于 2011-4-7 17:25:51 | 显示全部楼层 |阅读模式
本帖最后由 shenrenba 于 2011-4-8 13:14 编辑

代码如下 该如何解决
#include <GuiListView.au3>
#include <GuiMenu.au3>
#include <WindowsConstants.au3>
Global $m4,$m5,$m6
$hGUI = GUICreate("Test", 400, 300)
$hListView = _GUICtrlListView_Create($hGUI, "", 30, 20, 340, 200, BitOR($LVS_EDITLABELS, $LVS_REPORT))
_GUICtrlListView_SetExtendedListViewStyle($hListView, $LVS_EX_GRIDLINES)
_GUICtrlListView_InsertColumn($hListView, 0, "1", 50)
_GUICtrlListView_InsertColumn($hListView, 1, "2", 50)
_GUICtrlListView_InsertColumn($hListView, 2, "3", 100)
$Menu = _GUICtrlMenu_CreatePopup()
_GUICtrlMenu_InsertMenuItem($Menu, 0, "4", $m4)
_GUICtrlMenu_InsertMenuItem($Menu, 1, "5", $m5)
_GUICtrlMenu_InsertMenuItem($Menu, 2, "6", $m6)
GUISetState()
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
While GUIGetMsg() <> -3
WEnd
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
        Local $hWndFrom, $iCode, $tNMHDR, $iItemCount
        $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
        $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
        $iCode = DllStructGetData($tNMHDR, "Code")
        Switch $iCode
                Case $NM_RCLICK
                        If _GUICtrlMenu_TrackPopupMenu($Menu, $hListView, -1, -1, 1, 1, 2) = $m4 Then
                                MsgBox(0,0,4)
                        ElseIf _GUICtrlMenu_TrackPopupMenu($Menu, $hListView, -1, -1, 1, 1, 2) = $m5 Then
                                MsgBox(0,0,5)
                        ElseIf _GUICtrlMenu_TrackPopupMenu($Menu, $hListView, -1, -1, 1, 1, 2) = $m6 Then
                                MsgBox(0,0,6)
                        EndIf
        EndSwitch        
EndFunc
发表于 2011-4-7 19:35:50 | 显示全部楼层
看看我这个右键菜单,不知道和你那个是否一样,你试试吧!
http://www.autoitx.com/thread-17366-1-1.html
 楼主| 发表于 2011-4-8 09:26:28 | 显示全部楼层
回复 2# 水木子


     使用 _GUICtrlListView_Create 和GUICtrlCreateListView 创建的控件 不一样

    但是也谢谢了  我继续研究
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-10-2 10:39 , Processed in 0.147284 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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