#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#Include <GuiRebar.au3>
#include <GuiToolBar.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <GuiMenu.au3>
#Include <GuiStatusBar.au3>
#include <Constants.au3>
Global $idMenuInsert = 1000
$Gui = GUICreate("测试", 320, 200)
$hListView = _GUICtrlListView_Create($GUI, "连接数(0)", 10, 10, 300, 180, -1, $WS_EX_CLIENTEDGE)
_GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
_GUICtrlListView_SetColumnWidth($hListView, 0, 295)
;系统服务右键菜单
Global $ServerRightDisabled,$ServerRightManual,$ServerRightAuto,$ServerRightAllTask,$ServerRightRunning,$ServerRightStopped,$ServerRightRestart,$ServerRightRefresh,$ServerRightAttribute,$ServerRightHelpe,$ServerRightSubMemu,$ServerRightMemu
;子菜单
$ServerRightSubMemu =_GUICtrlMenu_CreatePopup()
_GUICtrlMenu_AddMenuItem($ServerRightMemu,"启动",$ServerRightRunning)
_GUICtrlMenu_AddMenuItem($ServerRightMemu,"停止",$ServerRightStopped)
_GUICtrlMenu_AddMenuItem($ServerRightMemu,"重新启动",$ServerRightRestart)
;主菜单
$ServerRightMemu =_GUICtrlMenu_CreatePopup()
_GUICtrlMenu_AddMenuItem($ServerRightMemu,"禁用",$ServerRightDisabled)
_GUICtrlMenu_AddMenuItem($ServerRightMemu,"手动",$ServerRightManual)
_GUICtrlMenu_AddMenuItem($ServerRightMemu,"自动",$ServerRightAuto)
_GUICtrlMenu_AddMenuItem($ServerRightMemu,"")
_GUICtrlMenu_AddMenuItem($ServerRightMemu,"所有任务",$ServerRightAllTask,$ServerRightSubMemu)
_GUICtrlMenu_AddMenuItem($ServerRightMemu,"")
_GUICtrlMenu_AddMenuItem($ServerRightMemu,"刷新",$ServerRightRefresh)
_GUICtrlMenu_AddMenuItem($ServerRightMemu,"")
_GUICtrlMenu_AddMenuItem($ServerRightMemu,"属性",$ServerRightAttribute)
_GUICtrlMenu_AddMenuItem($ServerRightMemu,"")
_GUICtrlMenu_AddMenuItem($ServerRightMemu,"帮助",$ServerRightHelpe)
GUISetState()
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
While 1
$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE
ExitLoop
EndSwitch
WEnd
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
Local $hWndFrom, $iCode, $tNMHDR, $hWndListView, $iItemCount
$hWndListView = $hListView
If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListView
Switch $iCode
Case $NM_RCLICK
_GUICtrlMenu_TrackPopupMenu($ServerRightMemu, $hListView, -1, -1, 1, 1, 2)
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc
如上代码中如何显示所有任务中的子菜单?