写了个多窗口多LV的框架,请A版指点看看可以不?供各位参考
前段时间经A版和各朋友的指点,终端于LisvtView有了一定的了解。为了方便后续与代码和提高可主动性,做了个框架:
1、包含多个窗口,
2、每个窗口有自己的按钮和表格
3、窗口表格通过左侧tree切换
4、当前表格信息显示在状态栏。
5、每个窗口有独立刷新按钮
6、表格回连确认修改
想请A版和各位朋友看看,是否可行,有没有什么问题隐患之类的?
同时也供新人参考。
#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 =
_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 = [['{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, $sRd, $aItem)
Case 1 ;第1表格
GUISwitch($hGuiC1)
Local $sRd = GUICtrlRead($iCombo), $sData = ''
_GUICtrlListView_SetItemText($hListView1, $aItem, $sRd, $aItem)
Case 2 ;第2表格
Local $sRd = GUICtrlRead($iCombo), $sData = ''
GUISwitch($hGuiC2)
_GUICtrlListView_SetItemText($hListView2, $aItem, $sRd, $aItem)
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 = [$index, $SubItem]
Local $sDef ;设置菜单为空
Global $sData = _GUICtrlListView_GetItemText($hListView0, $index, $SubItem)
GUICtrlSetPos($iCombo , $aRect + 204 , $aRect + 5 ,$aRect - $aRect)
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 = [$index, $SubItem]
Local $sDef ;设置菜单为空
Global $sData = _GUICtrlListView_GetItemText($hListView1, $index, $SubItem)
GUICtrlSetPos($iCombo , $aRect + 204 , $aRect + 8 ,$aRect - $aRect)
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 = [$index, $SubItem]
Local $sDef ;设置菜单为空
Global $sData = _GUICtrlListView_GetItemText($hListView2, $index, $SubItem)
GUICtrlSetPos($iCombo , $aRect + 204 , $aRect + 8 ,$aRect - $aRect)
GUICtrlSetData($iCombo, '|' & $sData, $sData)
GUICtrlSetState($iCombo, 256)
EndSwitch
EndSwitch
EndFunc ;==>_WM_NOTIFY
Func _Exit()
Exit
EndFunc ;==>_Exit
anythinging 发表于 2021-3-13 16:09
把主窗口与子窗口做一个程序 这句不是太懂
我的列子,你参考:
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUITreeView.au3>
#include <TreeViewConstants.au3>
#include <GuiListView.au3>
#include <WinAPI.au3>
#include <WinAPIEx.au3>
#include <GuiMenu.au3>
#include <GuiStatusBar.au3>
Opt("GUIOnEventMode", 1)
Opt('GUIResizeMode', 802)
Global $iWidtha = @DesktopWidth
Global $iHeighta = @DesktopHeight
Global $Input1, $hGUI, $WinMainSub2, $FormS3;$ES_NUMBER,$nCode,
Global $iWidtha = @DesktopWidth
Global $iHeighta = @DesktopHeight
Global $hGUI, $hGuiC1, $hGuiC2
Global $hGUI, $ListView1, $hListView1, $ListView2, $hListView2, $aItem, $iInput, $iCombo, $iCombo1, $iCombo2
Global $ListView0, $hListView0
Global $StatusBar
Global $ListViewNum = 1
Example()
While 1
Sleep(100)
WEnd
Func _EXIT()
GUIDelete()
Exit
EndFunc ;==>_EXIT
Func Example()
; 创建一个 GUI 及其各种控件.
Dim $hGUI = GUICreate("<" & @ScriptName & ">", $iWidtha - 210, $iHeighta - 258)
GUISetBkColor(0xfbfcfd)
GUISetOnEvent($GUI_EVENT_CLOSE, "_EXIT")
GUICtrlCreateButton('保存', 10, 550, 80, 25)
;GUICtrlSetOnEvent(-1,'_SaveListView0')
GUICtrlCreateButton('刷新', 110, 550, 80, 25)
; GUICtrlSetOnEvent(-1,'_ref0')
Local $idTreeview = GUICtrlCreateTreeView(2, 5, 200, 400, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
_GUICtrlTreeView_SetHeight($idTreeview, 25)
_GUICtrlTreeView_Expand($idTreeview)
_GUICtrlTreeView_SetBkColor($idTreeview, 0xfbfcfd);$COLOR_Turquoise)
_GUICtrlTreeView_SetTextColor($idTreeview, 0x990000)
_GUICtrlTreeView_SetLineColor($idTreeview, 0x009900);$COLOR_WHITE)
_GUICtrlTreeView_GetInsertMarkColor($idTreeview)
_GUICtrlTreeView_SetBold($idTreeview, True)
$hImage = _GUIImageList_Create(16, 16, 5, 1)
_GUIImageList_AddIcon($hImage, 'shell32.dll', 4)
_GUIImageList_AddIcon($hImage, 'shell32.dll', 137)
_GUIImageList_AddIcon($hImage, "shell32.dll", 165)
_GUIImageList_AddIcon($hImage, "shell32.dll", 168)
_GUIImageList_AddIcon($hImage, "shell32.dll", 39)
_GUIImageList_AddIcon($hImage, "shell32.dll", 146)
_GUICtrlTreeView_SetNormalImageList($idTreeview, $hImage)
_GUICtrlTreeView_SetBkColor($idTreeview, "0xEEE9D8")
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, 'TreeA')
GUICtrlSetState($idTreeviewA, $GUI_EXPAND)
$StatusBar = _GUICtrlStatusBar_Create($hGUI)
_WinAPI_SetWindowTheme($StatusBar, "", "")
Dim $StatusBar_PartsWidth =
_GUICtrlStatusBar_SetParts($StatusBar, $StatusBar_PartsWidth)
_GUICtrlStatusBar_SetText($StatusBar, @TAB & @YEAR & "年" & @MON & "月" & @MDAY & "日", 0)
_GUICtrlStatusBar_SetText($StatusBar, "当前表格 = 0", 1)
_GUICtrlStatusBar_SetText($StatusBar, "", 2)
; 设置背景颜色
_GUICtrlStatusBar_SetBkColor($StatusBar, _sRGB2BGR('0xC0CECE'))
_GUICtrlStatusBar_SetIcon($StatusBar, 0, _WinAPI_LoadShell32Icon(1));设置状态栏图标
_GUICtrlStatusBar_SetIcon($StatusBar, 1, _WinAPI_LoadShell32Icon(15));设置状态栏图标
_GUICtrlStatusBar_SetIcon($StatusBar, 2, _WinAPI_LoadShell32Icon(46));设置状态栏图标
_GUICtrlStatusBar_SetIcon($StatusBar, 3, _WinAPI_LoadShell32Icon(39));设置状态栏图标
_GUICtrlStatusBar_SetIcon($StatusBar, 4, _WinAPI_LoadShell32Icon(43));设置状态栏图标
_GUICtrlStatusBar_SetIcon($StatusBar, 5, _WinAPI_LoadShell32Icon(167));设置状态栏图标
Dim $WinMainSub2 = GUICreate("", 1000, 600, 205, 5, $WS_POPUP, 0x00000010 + 0x00000040 + 0x00000300, $hGUI)
GUISetBkColor(0xFFFFFF, $WinMainSub2)
GUISetState(@SW_SHOW, $WinMainSub2)
GUISetState(@SW_SHOW, $hGUI)
GUIRegisterMsg(0x004E, '_WM_NOTIFY') ;$WM_NOTIFY = 0x004E
TreeA1()
EndFunc ;==>Example
Func _sRGB2BGR($sRGB)
Return StringRegExpReplace(StringFormat('%06s', StringRegExpReplace($sRGB, '(?i)^0x', '')), '(?i)^(..)(..)(..)', '0x${3}${2}${1}')
EndFunc ;==>_sRGB2BGR
Func TreeA()
GUIDelete($WinMainSub2)
Local $nCode = GUICtrlRead($Input1)
Dim $WinMainSub2 = GUICreate("", 1000, 600, 205, 5, $WS_POPUP, 0x00000010 + 0x00000040 + 0x00000300, $hGUI)
GUISetBkColor(0xFFFFFF);0xFF00007F)
GUISetBkColor(0x4682B4)
GUICtrlCreateButton('保存', 10, 550, 80, 25)
;GUICtrlSetOnEvent(-1, '_SaveListView1')
GUICtrlCreateButton('刷新', 110, 550, 80, 25)
;GUICtrlSetOnEvent(-1, '_ref1')
Dim $ListView1 = GUICtrlCreateListView('用户名1 | 密码1 |管理员权限|管理', 1, 2, 296, 400)
Dim $hListView1 = GUICtrlGetHandle(-1)
For $i = 111 To 120
GUICtrlCreateListViewItem('' & $i & '|123456|普通用户' & $i & '|删除', $ListView1)
Next
$ListViewNum = 0
_GUICtrlStatusBar_SetText($StatusBar, '当前表格 = ' & $ListViewNum & '', 2)
GUISetState(@SW_SHOW, $WinMainSub2)
EndFunc ;==>TreeA
Func TreeA1()
GUIDelete($WinMainSub2)
Local $nCode = GUICtrlRead($Input1)
Dim $WinMainSub2 = GUICreate("", 1000, 600, 205, 5, $WS_POPUP, 0x00000010 + 0x00000040 + 0x00000300, $hGUI)
GUISetBkColor(0xFFFFFF);0xFF00007F)
GUISetBkColor(0x4682B4)
GUICtrlCreateButton('保存', 10, 550, 80, 25)
;GUICtrlSetOnEvent(-1, '_SaveListView1')
GUICtrlCreateButton('刷新', 110, 550, 80, 25)
;GUICtrlSetOnEvent(-1, '_ref1')
_GUICtrlStatusBar_SetText($StatusBar, '当前表格 = ' & $ListViewNum & '', 2)
Dim $ListView2 = GUICtrlCreateListView('用户名1 | 密码1 |管理员权限|管理', 1, 2, 296, 400)
Dim $hListView2 = GUICtrlGetHandle(-1)
For $i = 1 To 10
GUICtrlCreateListViewItem('' & $i & '|123456|普通用户' & $i & '|删除', $ListView2)
Next
GUISetState(@SW_SHOW, $WinMainSub2)
EndFunc ;==>TreeA1
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_DBLCLK = -3
Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
Local $index = DllStructGetData($tInfo, 'Index')
Local $SubItem = DllStructGetData($tInfo, 'SubItem')
Dim $aItem = 0
$index = _GUICtrlListView_GetSelectedIndices($ListView1)
$index1 = $index + 1
_GUICtrlStatusBar_SetText($StatusBar, '当前表格 = ' & $index1 & '', 2)
Local $cont = _GUICtrlListView_GetItemCount($hListView1);取得数组的行列数
$h1 = 0
For $id = 0 To $cont - 1
$str = _GUICtrlListView_GetItemTextArray($hListView1, $index)
$h1 = $str
$h2 = $str
$h3 = $str
$h4 = $str
$hA2 = $h1 & "=" & $h2 & "|" & $h3 & "|" & $h4
Next
MsgBox(0, "", "打开:" & $hA2)
Local $aRect = _GUICtrlListView_GetSubItemRect($hListView1, $index, $SubItem)
Dim $aItem = [$index, $SubItem]
Local $sDef ;设置菜单为空
Global $sData = _GUICtrlListView_GetItemText($hListView1, $index, $SubItem)
GUICtrlSetPos($iCombo, $aRect + 204, $aRect + 8, $aRect - $aRect)
GUICtrlSetData($iCombo, '|' & $sData, $sData)
GUICtrlSetState($iCombo, 256)
EndSwitch
Case $hListView2
Switch $iCode
Case -3 ;$NM_DBLCLK = -3
Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
Local $index = DllStructGetData($tInfo, 'Index')
Local $SubItem = DllStructGetData($tInfo, 'SubItem')
Dim $aItem = 0
$index = _GUICtrlListView_GetSelectedIndices($ListView2)
$index1 = $index + 1
_GUICtrlStatusBar_SetText($StatusBar, '当前表格 = ' & $index1 & '', 2)
Local $cont = _GUICtrlListView_GetItemCount($hListView2);取得数组的行列数
$h1 = 0
For $id = 0 To $cont - 1
$str = _GUICtrlListView_GetItemTextArray($hListView2, $index)
$h1 = $str
$h2 = $str
$h3 = $str
$h4 = $str
$hA2 = $h1 & "=" & $h2 & "|" & $h3 & "|" & $h4
Next
MsgBox(0, "", "打开:" & $hA2)
Local $aRect = _GUICtrlListView_GetSubItemRect($hListView2, $index, $SubItem)
Dim $aItem = [$index, $SubItem]
Local $sDef ;设置菜单为空
Global $sData = _GUICtrlListView_GetItemText($hListView2, $index, $SubItem)
GUICtrlSetPos($iCombo, $aRect + 204, $aRect + 8, $aRect - $aRect)
GUICtrlSetData($iCombo, '|' & $sData, $sData)
GUICtrlSetState($iCombo, 256)
EndSwitch
EndSwitch
EndFunc ;==>_WM_NOTIFY
没有处理窗口可调大小事件,那就去掉 23 行的 $WS_SIZEBOX 样式~
另外,在 WM_NOTIFY 消息中,几个列表相同处理部分完全可以以函数封装再调用(之前就给过例子),节省代码和维护成本 本帖最后由 anythinging 于 2021-3-7 12:05 编辑
afan 发表于 2021-3-7 11:43
没有处理窗口可调大小事件,那就去掉 23 行的 $WS_SIZEBOX 样式~
另外,在 WM_NOTIFY 消息中,几个列表相 ...
感谢A版指点!
1、确实做了窗口可调大小,遇到了一点小问题(手动调整正常,点窗口最大化时调整不到位,我又单独增加了个最大化的响应调整,发的时候没加那部份代码。
2、A版请教下,关于切换窗口显示表格的TreeA1 A2,会不会有点啰嗦,我测试中发现如果不对表格进行隐藏(仅对子窗口隐藏),还是会影响到当前表格的操作。
3、目前对 WM_NOTIFY 消息的掌握,仅仅是套用阶段,惭愧。
学习。学习。学习。学习。 学习。学习。学习,源碼我就收下了 本帖最后由 chzj589 于 2021-3-9 10:03 编辑
anythinging 发表于 2021-3-7 11:59
感谢A版指点!
1、确实做了窗口可调大小,遇到了一点小问题(手动调整正常,点窗口最大化时调整不到位, ...
主窗口可调大小,但子窗口不能调大?
把列表放进子窗口就不用隐藏。
本帖最后由 anythinging 于 2021-3-13 15:40 编辑
chzj589 发表于 2021-3-9 10:00
主窗口可调大小,但子窗口不能调大?
把列表放进子窗口就不用隐藏。
感谢指点,窗口调整我上面发的是没有问题的。
1、但加了很多代码后,调整窗口位置和大小都有问题:点击最大化后调整不到位的情况,暂时把最大化窗口做了个单独响应进行调整位置,解决了。还没来得及查看差在哪里了。
2、我发现如果操作listvew时,如果仅隐藏其它子窗口而不对其它listview进行隐藏,会影响到当前表格的操作
本帖最后由 chzj589 于 2021-3-13 16:08 编辑
anythinging 发表于 2021-3-13 15:29
感谢指点,窗口调整我上面发的是没有问题的。
1、但加了很多代码后,调整窗口位置和大小都有问题:点击 ...
把主窗口与子窗口做一个程序,因是事件模式,互不干扰。
要更新或增加程序也简单。都在一个窗口里。再添加一个子窗口的代码就行 chzj589 发表于 2021-3-13 16:07
把主窗口与子窗口做一个程序,因是事件模式,互不干扰。
要更新或增加程序也简单。都在一个窗口里。再添 ...
把主窗口与子窗口做一个程序 这句不是太懂 chzj589 发表于 2021-3-13 16:15
我的列子,你参考:
#include
#include
我懂了,感谢指点!
用同一个子窗口,切换窗口的时候,直接删除上一个(一了百了),不用再考虑显示隐藏之类的麻烦事了!
页:
[1]