本帖最后由 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
|