#NoTrayIcon
#include <TreeViewConstants.au3>
#include <GuiMenu.au3>
#include <GuiListView.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUITreeView.au3>
Global $hGui, $hGuiSub, $Sub1gui, $hMenu
Global $ListView1, $hListView1, $aItem, $iInput, $iCombo
Opt("GUIOnEventMode", 1)
CreateGUI()
While 1
Sleep(1000)
WEnd
Func _Exit()
Exit
EndFunc ;==>_Exit
Func CreateGUI()
$hGui = GUICreate("主窗口", 1200, 600, -1, -1);, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX))
GUISetOnEvent($GUI_EVENT_CLOSE, "_EXIT")
Local $idTreeview = GUICtrlCreateTreeView(2, 3, 200, 400, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
Local $idTreeviewA = GUICtrlCreateTreeViewItem("Tree", $idTreeview)
Local $idTreeviewA1 = GUICtrlCreateTreeViewItem("表1", $idTreeviewA)
GUICtrlSetOnEvent(-1, '_idTreeviewA1')
Local $idTreeviewA2 = GUICtrlCreateTreeViewItem("表2", $idTreeviewA)
GUICtrlSetOnEvent(-1, '_idTreeviewA2')
_GUICtrlTreeView_SetHeight($idTreeview, 20)
_GUICtrlTreeView_ExpandedOnce($idTreeview, $idTreeviewA)
_GUICtrlTreeView_Expand($idTreeview, $idTreeviewA1)
Dim $iCombo = GUICtrlCreateCombo('', -100, -100)
;~ ------------------------- 子窗口 1 ------------------------------
$hGuiSub = GUICreate("子窗口1", 985, 585, 205, 1, $WS_POPUP, 0x00000010 + 0x00000040 + 0x00000100, $hGui)
Dim $ListView1 = GUICtrlCreateListView('用户名1 | 密码1 |性别|管理', 1, 2, 296, 350)
Dim $hListView1 = GUICtrlGetHandle(-1)
For $i = 1 To 10
GUICtrlCreateListViewItem('' & $i & '|123456|男|删除', $ListView1)
Next
GUISetState(@SW_SHOW, $hGuiSub)
GUISetState(@SW_SHOW, $hGui)
GUIRegisterMsg(0x004E, '_WM_NOTIFY') ;$WM_NOTIFY = 0x004E
Local $id1 = GUICtrlCreateDummy()
GUICtrlSetOnEvent(-1, '_UdpData')
Local $aAccelKeys[1][2] = [['{Enter}', $id1]]
GUISetAccelerators($aAccelKeys)
Local $context = GUICtrlCreateContextMenu(GUICtrlCreateDummy())
Dim $hMenu = GUICtrlGetHandle($context)
GUICtrlCreateMenuItem('男', $context)
GUICtrlCreateMenuItem('女', $context)
EndFunc ;==>CreateGUI
Func _WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch DllStructGetData($tNMHDR, 'hWndFrom')
Case $hListView1
Switch $iCode
Case -3 ;$NM_CLICK = -2 ;$NM_DBLCLK = -3
If IsArray($aItem) Then
_UdpData()
EndIf
Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
Local $index = DllStructGetData($tInfo, 'Index')
Local $SubItem = DllStructGetData($tInfo, 'SubItem')
If Not StringRegExp($SubItem, "^(2)$") Then Return 'GUI_RUNDEFMSG'
If $SubItem = 2 Then
Local $iid = _GUICtrlMenu_TrackPopupMenu($hMenu, $hGui, -1, -1, 1, 1, 2)
If $iid Then _GUICtrlListView_SetItemText($hListView1, $index, _GUICtrlMenu_GetItemText($hMenu, $iid, False), 2)
EndIf
EndSwitch
EndSwitch
EndFunc ;==>_WM_NOTIFY
Func _UdpData()
If Not IsArray($aItem) Then Return
Local $sRd = GUICtrlRead($iCombo), $sData = ''
_GUICtrlListView_SetItemText($hListView1, $aItem[0], $sRd, $aItem[1])
GUICtrlSetPos($iCombo, -1000, -100)
Dim $aItem = 0
EndFunc ;==>_UdpData
Func _idTreeviewA1()
GUIDelete($hGuiSub)
;~ ------------------------- 子窗口 2 ------------------------------
$hGuiSub = GUICreate("子窗口2", 985, 585, 205, 1, $WS_POPUP, 0x00000010 + 0x00000040 + 0x00000300, $hGui)
GUISetBkColor(0x4682B4)
;GUISetState()
Dim $ListView1 = GUICtrlCreateListView('用户名1 | 密码1 |性别|管理', 1, 2, 296, 350)
Dim $hListView1 = GUICtrlGetHandle(-1)
For $i = 1 To 10
GUICtrlCreateListViewItem('' & $i & '|123456|男|删除', $ListView1)
Next
GUICtrlCreateButton('添 加', 110, 550, 80, 25)
GUICtrlSetOnEvent(-1, '_Sub1Add')
GUISetState(@SW_SHOW, $hGuiSub)
EndFunc ;==>_idTreeviewA1
Func _Sub1Add()
$Sub1gui = GUICreate('', 300, 200, -1, -1)
GUICtrlCreateButton('关 闭', 10, 50, 60, 25)
GUICtrlSetOnEvent(-1, '_Sub1Close')
GUISetState()
EndFunc ;==>_Sub1Add
Func _Sub1Close()
GUIDelete($Sub1gui)
;~ GUISetState(@SW_HIDE ,$Sub1gui)
;~ TreeA1() ;临时解决方法
EndFunc ;==>_Sub1Close
Func _idTreeviewA2()
GUIDelete($hGuiSub)
;~ ------------------------- 子窗口 3 ------------------------------
$hGuiSub = GUICreate("子窗口3", 985, 585, 205, 1, $WS_POPUP, 0x00000010 + 0x00000040 + 0x00000200, $hGui)
GUISetBkColor(0x4682B4)
;GUISetState()
Dim $ListView1 = GUICtrlCreateListView('用户名1 | 密码1 |性别|管理', 1, 2, 296, 350)
Dim $hListView1 = GUICtrlGetHandle(-1)
For $i = 1 To 10
GUICtrlCreateListViewItem('' & $i & '|56789' & $i & '|男|删除', $ListView1)
Next
GUICtrlCreateButton('添 加', 110, 550, 80, 25)
GUICtrlSetOnEvent(-1, '_Sub1Add')
GUISetState(@SW_SHOW, $hGuiSub)
EndFunc ;==>_idTreeviewA2