#Region ;**** 编译指令由 by AutoIt3Wrapper_GUI 创建 ****
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_Res_Language=2052
#include <WinAPI.au3>
#include <WinAPIEx.au3>
#include <TreeViewConstants.au3>
#include <GuiMenu.au3>
#include <GuiListView.au3>
#include <GuiStatusBar.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $hGui,$hGuiC1,$hGuiC2
Global $hGUI, $ListView1, $hListView1, $ListView2, $hListView2,$aItem, $iInput, $iCombo,$iCombo1,$iCombo2
Global $ListView0, $hListView0
Global $StatusBar
Global $fIni = 'test.ini'
Global $ListViewNum = 1
Opt("GUIOnEventMode", 1)
CreateGUI()
Func CreateGUI()
$hGUI = GUICreate("主窗口", 1200, 600, -1, -1,BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX))
GUISetOnEvent($GUI_EVENT_CLOSE,"_EXIT")
GUISetState()
GUICtrlCreateButton('保 存',10,550,80,25)
GUICtrlSetOnEvent(-1,'_SaveListView0')
GUICtrlCreateButton('刷 新',110,550,80,25)
GUICtrlSetOnEvent(-1,'_ref0')
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)
GUICtrlSetOnEvent(-1,'TreeA')
Local $idTreeviewA1 = GUICtrlCreateTreeViewItem("窗口1表1", $idTreeviewA)
GUICtrlSetOnEvent(-1,'TreeA1')
Local $idTreeviewA2 = GUICtrlCreateTreeViewItem("窗口2表2", $idTreeviewA)
GUICtrlSetOnEvent(-1,'TreeA2')
GUICtrlSetState($idTreeviewA, $GUI_EXPAND)
$StatusBar = _GUICtrlStatusBar_Create($hGUI)
_WinAPI_SetWindowTheme($StatusBar, "", "")
Dim $StatusBar_PartsWidth[3] = [205, 450,-1]
_GUICtrlStatusBar_SetParts($StatusBar, $StatusBar_PartsWidth)
_GUICtrlStatusBar_SetText($StatusBar, "", 0)
_GUICtrlStatusBar_SetText($StatusBar, "当前表格 = 0", 1)
_ListView0()
Dim $iCombo = GUICtrlCreateCombo('', -100, -100)
GUIRegisterMsg(0x004E, '_WM_NOTIFY') ;$WM_NOTIFY = 0x004E
Local $id1 = GUICtrlCreateDummy()
GUICtrlSetOnEvent(-1, '_UdpData')
Local $aAccelKeys[1][2] = [['{Enter}', $id1]]
GUISetAccelerators($aAccelKeys)
Global $aItem
;~ ------------------------- 子窗口 1 ------------------------------
$hGuiC1 = GUICreate("子窗口1", 1000, 600, 201, 1, $WS_CHILD, $WS_EX_CLIENTEDGE, $hGUI)
GUISetBkColor(0x4682B4)
GUICtrlCreateButton('保 存',10,550,80,25)
GUICtrlSetOnEvent(-1,'_SaveListView1')
GUICtrlCreateButton('刷 新',110,550,80,25)
GUICtrlSetOnEvent(-1,'_ref1')
_ListView1()
;~ ------------------------- 子窗口 2 ------------------------------
$hGuiC2 = GUICreate("子窗口2", 1000, 600, 201, 1, $WS_CHILD, $WS_EX_CLIENTEDGE, $hGUI)
GUISetBkColor(0x444444)
GUICtrlCreateButton('保 存',10,550,80,25)
GUICtrlSetOnEvent(-1,'_SaveListView2')
GUICtrlCreateButton('刷 新',110,550,80,25)
GUICtrlSetOnEvent(-1,'_ref2')
_ListView2()
While 1
Sleep(10)
WEnd
EndFunc
Func TreeA()
If IsArray($aItem) Then
_UdpData()
EndIf
$ListViewNum = 0
_GUICtrlStatusBar_SetText($StatusBar, '当前表格 = '&$ListViewNum&'', 1)
GUISwitch($hGui)
GUISetState(@SW_SHOW,$hGui)
GUISetState(@SW_HIDE,$hGuiC1)
GUISetState(@SW_HIDE,$hGuiC2)
GUICtrlSetState($ListView0,$GUI_SHOW)
GUICtrlSetState($ListView1,$GUI_HIDE)
GUICtrlSetState($ListView2,$GUI_HIDE)
EndFunc
Func TreeA1()
If IsArray($aItem) Then
_UdpData()
EndIf
$ListViewNum = 1
_GUICtrlStatusBar_SetText($StatusBar, '当前表格 = '&$ListViewNum&'', 1)
GUISwitch($hGuiC1)
GUISetState(@SW_SHOW,$hGuiC1)
GUISetState(@SW_HIDE,$hGuiC2)
GUICtrlSetState($ListView1,$GUI_SHOW)
GUICtrlSetState($ListView0,$GUI_HIDE)
GUICtrlSetState($ListView2,$GUI_HIDE)
EndFunc
Func TreeA2()
If IsArray($aItem) Then
_UdpData()
EndIf
$ListViewNum = 2
_GUICtrlStatusBar_SetText($StatusBar, '当前表格 = '&$ListViewNum&'', 1)
GUISwitch($hGuiC1)
GUISetState(@SW_SHOW,$hGuiC2)
GUISetState(@SW_HIDE,$hGuiC1)
GUICtrlSetState($ListView2,$GUI_SHOW)
GUICtrlSetState($ListView0,$GUI_HIDE)
GUICtrlSetState($ListView1,$GUI_HIDE)
EndFunc
Func _ListView0()
Dim $ListView0 = GUICtrlCreateListView('用户名A | 密码 |管理员权限|管理', 203, 2, 296, 350)
Dim $hListView0 = GUICtrlGetHandle(-1)
For $i = 111 to 120
GUICtrlCreateListViewItem(''&$i&'|123456|普通用户'&$i&'|删除', $ListView0)
Next
$ListViewNum = 0
_GUICtrlStatusBar_SetText($StatusBar, '当前表格 = '&$ListViewNum&'', 1)
EndFunc
Func _ListView1()
Dim $ListView1 = GUICtrlCreateListView('用户名1 | 密码1 |管理员权限|管理', 1, 2, 296, 350)
Dim $hListView1 = GUICtrlGetHandle(-1)
For $i = 1 to 10
GUICtrlCreateListViewItem(''&$i&'|123456|普通用户'&$i&'|删除', $ListView1)
Next
EndFunc
Func _ListView2()
Dim $ListView2 = GUICtrlCreateListView('用户名2 | 密码2 |管理员权限2|管理2', 1, 2, 296, 350)
Dim $hListView2 = GUICtrlGetHandle(-1)
For $i = 11 to 20
GUICtrlCreateListViewItem(''&$i&'|123456|普通用户'&$i&'|删除', $ListView2)
Next
EndFunc
Func _SaveListView0()
MsgBox(262144,'','保存0',1)
EndFunc
Func _SaveListView1()
MsgBox(262144,'','保存1',1)
EndFunc
Func _SaveListView2()
MsgBox(262144,'','保存2',1)
EndFunc
Func _ref0()
GUISwitch($hGui)
GUICtrlDelete($ListView0)
_listView0()
$ListViewNum = 0
_GUICtrlStatusBar_SetText($StatusBar, '当前表格 = '&$ListViewNum&'', 1)
GUICtrlSetState($ListView0,$GUI_SHOW)
EndFunc
Func _ref1()
GUISwitch($hGuiC1)
GUICtrlDelete($ListView1)
_listView1()
$ListViewNum = 1
_GUICtrlStatusBar_SetText($StatusBar, '当前表格 = '&$ListViewNum&'', 1)
GUICtrlSetState($ListView1,$GUI_SHOW)
EndFunc
Func _ref2()
GUISwitch($hGuiC2)
GUICtrlDelete($ListView2)
_listView2()
$ListViewNum = 2
_GUICtrlStatusBar_SetText($StatusBar, '当前表格 = '&$ListViewNum&'', 1)
GUICtrlSetState($ListView2,$GUI_SHOW)
EndFunc
Func _UdpData()
If Not IsArray($aItem) Then Return
Switch $ListViewNum
Case 0
GUISwitch($hGui)
Local $sRd = GUICtrlRead($iCombo), $sData = ''
_GUICtrlListView_SetItemText($hListView0, $aItem[0], $sRd, $aItem[1])
Case 1 ;第1表格
GUISwitch($hGuiC1)
Local $sRd = GUICtrlRead($iCombo), $sData = ''
_GUICtrlListView_SetItemText($hListView1, $aItem[0], $sRd, $aItem[1])
Case 2 ;第2表格
Local $sRd = GUICtrlRead($iCombo), $sData = ''
GUISwitch($hGuiC2)
_GUICtrlListView_SetItemText($hListView2, $aItem[0], $sRd, $aItem[1])
EndSwitch
GUICtrlSetPos($iCombo, -1000, -100)
Dim $aItem = 0
EndFunc
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 $hListView0
Switch $iCode
Case -2 ;$NM_CLICK = -2
If IsArray($aItem) Then
_UdpData()
EndIf
Case -3 ;$NM_DBLCLK = -3
Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
Local $index = DllStructGetData($tInfo, 'Index')
Local $SubItem = DllStructGetData($tInfo, 'SubItem')
Dim $aItem = 0
Local $aRect = _GUICtrlListView_GetSubItemRect($hListView0, $index, $SubItem)
Dim $aItem[2] = [$index, $SubItem]
Local $sDef ;设置菜单为空
Global $sData = _GUICtrlListView_GetItemText($hListView0, $index, $SubItem)
GUICtrlSetPos($iCombo , $aRect[0] + 204 , $aRect[1] + 5 ,$aRect[2] - $aRect[0])
GUICtrlSetData($iCombo, '|' & $sData, $sData)
GUICtrlSetState($iCombo, 256)
EndSwitch
Case $hListView1
Switch $iCode
Case -2 ;$NM_CLICK = -2
If IsArray($aItem) Then
_UdpData()
EndIf
Case -3 ;$NM_DBLCLK = -3
Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
Local $index = DllStructGetData($tInfo, 'Index')
Local $SubItem = DllStructGetData($tInfo, 'SubItem')
Dim $aItem = 0
Local $aRect = _GUICtrlListView_GetSubItemRect($hListView1, $index, $SubItem)
Dim $aItem[2] = [$index, $SubItem]
Local $sDef ;设置菜单为空
Global $sData = _GUICtrlListView_GetItemText($hListView1, $index, $SubItem)
GUICtrlSetPos($iCombo , $aRect[0] + 204 , $aRect[1] + 8 ,$aRect[2] - $aRect[0])
GUICtrlSetData($iCombo, '|' & $sData, $sData)
GUICtrlSetState($iCombo, 256)
EndSwitch
Case $hListView2
Switch $iCode
Case -2 ;$NM_CLICK = -2
If IsArray($aItem) Then
_UdpData()
EndIf
Case -3 ;$NM_DBLCLK = -3
Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
Local $index = DllStructGetData($tInfo, 'Index')
Local $SubItem = DllStructGetData($tInfo, 'SubItem')
Dim $aItem = 0
Local $aRect = _GUICtrlListView_GetSubItemRect($hListView2, $index, $SubItem)
Dim $aItem[2] = [$index, $SubItem]
Local $sDef ;设置菜单为空
Global $sData = _GUICtrlListView_GetItemText($hListView2, $index, $SubItem)
GUICtrlSetPos($iCombo , $aRect[0] + 204 , $aRect[1] + 8 ,$aRect[2] - $aRect[0])
GUICtrlSetData($iCombo, '|' & $sData, $sData)
GUICtrlSetState($iCombo, 256)
EndSwitch
EndSwitch
EndFunc ;==>_WM_NOTIFY
Func _Exit()
Exit
EndFunc ;==>_Exit