chzj589
发表于 2023-10-31 16:29:14
chzj589 发表于 2023-10-31 16:03
不要灰心,鼓励一下
xuanniao110
发表于 2023-10-31 20:38:49
chzj589 发表于 2023-10-31 16:29
我就不发代码了,发2个图对比下吧,哈哈
chzj589
发表于 2023-10-31 21:26:03
xuanniao110 发表于 2023-10-31 20:38
我就不发代码了,发2个图对比下吧,哈哈
下面这段我还没弄懂
$index = Number(_GUICtrlListView_GetSelectedIndices($Listview1))
$cs = _GUICtrlListView_GetItemCount($Listview1)
$i = GUICtrlRead($StatusBar1, 1)
For $i = 0 To $cs - 1
$z = _GUICtrlStatusBar_GetText($StatusBar1, 3)
$m = _GUICtrlStatusBar_GetText($StatusBar1, 5)
$x = $z + 1
$y = $m + 1
$add = _GUICtrlListView_GetItemText($Listview1, $i, 2)
$dkh = _GUICtrlListView_GetItemText($Listview1, $i, 3)
_GUICtrlStatusBar_SetText($StatusBar1, $i, 1)
TCPStartup() ; 开始 TCP 服务
Local $socket = TCPConnect($add, $dkh)
If $socket = -1 Then
TCPShutdown() ; 停止 TCP 服务
$b = 1
_GUICtrlStatusBar_SetText($StatusBar1, @TAB & $y, 5)
Else
TCPShutdown() ; 停止 TCP 服务
$b = 2
_GUICtrlStatusBar_SetText($StatusBar1, @TAB & $x, 3)
EndIf
Next
xuanniao110
发表于 2023-10-31 21:35:03
本帖最后由 xuanniao110 于 2023-10-31 21:36 编辑
chzj589 发表于 2023-10-31 21:26
下面这段我还没弄懂
_GUICtrlStatusBar_SetText($StatusBar1, "", 3);清空状态栏在线的文本
_GUICtrlStatusBar_SetText($StatusBar1, "", 5);清空状态栏离线的文本
_GUICtrlStatusBar_SetText($StatusBar1, "正在检测设备通讯……", 0)
;~ $index = Number(_GUICtrlListView_GetSelectedIndices($Listview1))
$cs = _GUICtrlListView_GetItemCount($Listview1)
$i = GUICtrlRead($StatusBar1, 1)
For $i = 0 To $cs - 1
$z = _GUICtrlStatusBar_GetText($StatusBar1, 3);在线
$m = _GUICtrlStatusBar_GetText($StatusBar1, 5);离线
$x = $z + 1;循环加1
$y = $m + 1;循环加1
$add = _GUICtrlListView_GetItemText($Listview1, $i, 2);获取子项的文本
$dkh = _GUICtrlListView_GetItemText($Listview1, $i, 3));获取子项的文本
_GUICtrlStatusBar_SetText($StatusBar1, $i, 1);设定状态栏的文本
TCPStartup() ; 开始 TCP 服务
Local $socket = TCPConnect($add, $dkh);检测IP 端口
If $socket = -1 Then;如果是-1,则不通
TCPShutdown() ; 停止 TCP 服务
$b = 1
_GUICtrlStatusBar_SetText($StatusBar1, @TAB & $y, 5);设定状态栏5 离线的文本
Else;反之则通
TCPShutdown() ; 停止 TCP 服务
$b = 2
_GUICtrlStatusBar_SetText($StatusBar1, @TAB & $x, 3);设定状态栏3 在线的文本
EndIf
Next
_GUICtrlStatusBar_SetText($StatusBar1, "总共" & $cs & "台设备", 0);设定状态栏0的文本
_GUICtrlStatusBar_SetText($StatusBar1, "", 1);清空状态栏1的文本
chzj589
发表于 2023-11-1 09:22:36
xuanniao110 发表于 2023-10-31 21:35
是判断的问题,
TCPStartup() ; 开始 TCP 服务
Local $socket = TCPConnect($add, $dkh);检测IP 端口
If $socket = -1 Then;如果是-1,则不通
TCPShutdown() ; 停止 TCP 服务
$b = 1
_GUICtrlStatusBar_SetText($StatusBar1, @TAB & $y, 5);设定状态栏5 离线的文本
Else;反之则通
TCPShutdown() ; 停止 TCP 服务
$b = 2
_GUICtrlStatusBar_SetText($StatusBar1, @TAB & $x, 3);设定状态栏3 在线的文本
EndIf
把"×"与"√"写入数据库就通过
chzj589
发表于 2023-11-1 09:58:29
xuanniao110 发表于 2023-10-31 21:35
我是笔记本电脑,无法判断测试。既然写入数据库可以通过,那就依样画葫芦试试
Func updataa()
Local $P, $x = 0, $y = 0, $ii = 0
Local $a = 0, $b = 0, $aa = 0
Local $socket
_GUICtrlStatusBar_GetText($StatusBar1, 3);在线
_GUICtrlStatusBar_GetText($StatusBar1, 5);离线
;_GUICtrlStatusBar_SetText($StatusBar1, "正在检测设备通讯……", 0)
GUICtrlSendMsg($Listview1, $LVM_DELETEALLITEMS, 0, 0)
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password=" & $DBPswd)
$RS = ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.open("SELECT COUNT(*) FROM Radmin");
While (Not $RS.eof And Not $RS.bof);
$P = $RS.Fields(0).value
$RS.movenext;
WEnd;
$RS.close;
Dim $APP[$P]
$i = 0
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password=" & $DBPswd)
$RS = ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.open("SELECT* fromRadmin");
While (Not $RS.eof And Not $RS.bof);
$APP[$i] = $RS.Fields(0).value
$APP[$i] = $RS.Fields(1).value
$APP[$i] = $RS.Fields(2).value
$APP[$i] = $RS.Fields(3).value
$APP[$i] = $RS.Fields(4).value
$APP[$i] = $RS.Fields(5).value
$i = $i + 1
$add = $RS.Fields(2).value
$dkh = $RS.Fields(3).value
;MsgBox(0, $P, $add& @CRLF&$dkh, 1)
TCPStartup() ; 开始 TCP 服务
Local $socket = TCPConnect($add, $dkh)
If $socket = -1 Then
TCPShutdown() ; 停止 TCP 服务
$b = 1
$y += 1
_GUICtrlStatusBar_SetText($StatusBar1, @TAB & $y, 5)
Else
TCPShutdown() ; 停止 TCP 服务
$b = 2
$x += 1
_GUICtrlStatusBar_SetText($StatusBar1, @TAB & $x, 3)
EndIf
_GUICtrlStatusBar_SetText($StatusBar1, "正在检测设备通讯……" & $ii, 1)
$ii += 1
$RS.movenext;
WEnd;
$RS.close;
For $x = 0 To $P - 1
_GUICtrlListView_AddItem($Listview1, $APP[$x], 0, -1)
_GUICtrlListView_AddSubItem($Listview1, $x, $APP[$x], 1, 0)
_GUICtrlListView_AddSubItem($Listview1, $x, $APP[$x], 2, -1)
_GUICtrlListView_AddSubItem($Listview1, $x, $APP[$x], 3, -1)
_GUICtrlListView_AddSubItem($Listview1, $x, $APP[$x], 4, -1)
_GUICtrlListView_AddSubItem($Listview1, $x, "******", 5, -1);"******",
If $b <= 1 Then
$a = "×"
$b = 1
Else
$a = "√"
$b = 2
EndIf
_GUICtrlListView_AddSubItem($Listview1, $x, $a, 7, $b)
Next
_GUICtrlStatusBar_SetText($StatusBar1, "总共" & $P & "台设备", 0)
_GUICtrlStatusBar_SetText($StatusBar1, "", 1)
_GUICtrlListView_RegisterSortCallBack($Listview1)
_GUICtrlListView_SortItems($Listview1, 0);以ID排序
_GUICtrlListView_SortItems($Listview1, GUICtrlGetState($Listview1))
_GUICtrlListView_UnRegisterSortCallBack($Listview1)
EndFunc ;==>updataa
xuanniao110
发表于 2023-11-2 09:20:13
chzj589 发表于 2023-11-1 09:58
我是笔记本电脑,无法判断测试。既然写入数据库可以通过,那就依样画葫芦试试
不变色,算了
chzj589
发表于 2023-11-2 09:58:46
本帖最后由 chzj589 于 2023-11-2 10:13 编辑
xuanniao110 发表于 2023-11-2 09:20
不变色,算了
还有一个方法,再试试
#AutoIt3Wrapper_UseX64=n
##include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GuiStatusBar.au3>
#include <GuiListView.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPIEx.au3>
#include <EditConstants.au3>
#include <GuiIPAddress.au3>
#include <GuiImageList.au3>
#include <GuiEdit.au3>
#include <GUIComboBox.au3>
#include <GuiConstantsEx.au3>
#include <Array.au3>
#include <GuiButton.au3>
#include <ModernMenuRaw.au3>
#include <GUIConstants.au3>
#PRE_UseX64=n
;数据库定义
Global Const $$DBName = "Data.mdb"
Global Const $$DBPswd = "answerx"
Dim $$array
Global $$data = 10
Global $$dataArray[$$data]
Global $$a, $$b
;常量定义区
Global Const $$ODT_LISTVIEW = 102
Global Const $$ODA_DRAWENTIRE = 0x1
Global Const $$ODA_SELECT = 0x2
Global Const $$ODA_FOCUS = 0x4
Global Const $$ODS_SELECTED = 0x0001
$$Form1 = GUICreate("Form1", 603, 698, 270, -1)
DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 1)
$$Button5 = GUICtrlCreateButton("在线检测", 390, 71, 70, 25);, $$BS_FLAT)
$$Listview1 = GUICtrlCreateListView("", 3, 104, 597, 566, BitOR($$LVS_REPORT, $$LVS_SHOWSELALWAYS))
Dim $$hListview1 = GUICtrlGetHandle(-1)
GUICtrlSetBkColor(-1, 0xB5B5B5)
$$iStyle = BitOR($$LVS_EX_FULLROWSELECT, $$LVS_EX_GRIDLINES, $$WS_EX_CLIENTEDGE, $$LVS_EX_SUBITEMIMAGES, $$LVS_EX_DOUBLEBUFFER)
_GUICtrlListView_SetExtendedListViewStyle($$Listview1, $$iStyle)
; 设置颜色
;_GUICtrlListView_SetTextBkColor($$Listview1, 0xFFE0C0);$$CLR_MONEYGREEN)
_GUICtrlListView_SetBkColor($$Listview1, 14675183);$$CLR_MONEYGREEN)
_GUICtrlListView_AddColumn($$Listview1, "ID", 0)
_GUICtrlListView_AddColumn($$Listview1, "名称", 95)
_GUICtrlListView_AddColumn($$Listview1, "IP地址", 120)
_GUICtrlListView_AddColumn($$Listview1, "端口", 85)
_GUICtrlListView_AddColumn($$Listview1, "用户名", 82)
_GUICtrlListView_AddColumn($$Listview1, "密码", 63)
_GUICtrlListView_AddColumn($$Listview1, "", 4)
_GUICtrlListView_AddColumn($$Listview1, "在线", 57)
; 加载图像
$$hImage = _GUIImageList_Create()
_GUIImageList_AddIcon($$hImage, @SystemDir & "\shell32.dll", 110) ;0
_GUIImageList_AddIcon($$hImage, @SystemDir & "\shell32.dll", 131);1
_GUIImageList_AddIcon($$hImage, @SystemDir & "\shell32.dll", 137)
_GUICtrlListView_SetImageList($$Listview1, $$hImage, 1)
Dim $$RC_menu, $$RC0, $$RC1, $$RC2, $$RC3, $$RC4
$$RC_menu = GUICtrlCreateContextMenu($$Listview1)
$$RC0 = _GUICtrlCreateODMenuItem("完全控制", $$RC_menu, "Radmin.exe", -16)
GUICtrlCreateMenuItem("", $$RC_menu)
$$RC1 = _GUICtrlCreateODMenuItem("添加连接", $$RC_menu, "Radmin.exe", -9)
$$RC2 = _GUICtrlCreateODMenuItem("编辑连接", $$RC_menu, "Radmin.exe", -10)
$$RC3 = _GUICtrlCreateODMenuItem("删除连接", $$RC_menu, "Radmin.exe", -8)
GUICtrlCreateMenuItem("", $$RC_menu)
$$RC4 = _GUICtrlCreateODMenuItem("是否在线", $$RC_menu, "Radmin.exe", -14)
$$StatusBar1 = _GUICtrlStatusBar_Create($$Form1)
Dim $$StatusBar1_PartsWidth =
_GUICtrlStatusBar_SetParts($$StatusBar1, $$StatusBar1_PartsWidth)
_GUICtrlStatusBar_SetText($$StatusBar1, "", 0)
_GUICtrlStatusBar_SetText($$StatusBar1, "", 1)
_GUICtrlStatusBar_SetText($$StatusBar1, "在线", 2)
_GUICtrlStatusBar_SetText($$StatusBar1, @TAB & "", 3)
_GUICtrlStatusBar_SetText($$StatusBar1, "离线", 4)
_GUICtrlStatusBar_SetText($$StatusBar1, @TAB & "", 5)
GUISetState(@SW_SHOW)
updata()
GUIRegisterMsg($$WM_NOTIFY, "WM_NOTIFY")
While 1
$$nMsg = GUIGetMsg()
Switch $$nMsg
Case $$GUI_EVENT_CLOSE;, $$ListBut_2
Exit
Case $$Button5
updata()
_GUICtrlStatusBar_SetText($$StatusBar1, "", 3)
_GUICtrlStatusBar_SetText($$StatusBar1, "", 5)
_GUICtrlStatusBar_SetText($$StatusBar1, "正在检测设备通讯……", 0)
$$index = Number(_GUICtrlListView_GetSelectedIndices($$Listview1))
$$cs = _GUICtrlListView_GetItemCount($$Listview1)
$$i = GUICtrlRead($$StatusBar1, 1)
For $$i = 0 To $$cs - 1
$$z = _GUICtrlStatusBar_GetText($$StatusBar1, 3)
$$m = _GUICtrlStatusBar_GetText($$StatusBar1, 5)
$$x = $$z + 1
$$y = $$m + 1
$$add = _GUICtrlListView_GetItemText($$Listview1, $$i, 2)
$$dkh = _GUICtrlListView_GetItemText($$Listview1, $$i, 3)
_GUICtrlStatusBar_SetText($$StatusBar1, $$i, 1)
TCPStartup() ; 开始 TCP 服务
Local $$socket = TCPConnect($$add, $$dkh)
If $$socket = -1 Then
TCPShutdown() ; 停止 TCP 服务
_GUICtrlListView_SetItemText($$Listview1, $$i, "×", 7)
_GUICtrlStatusBar_SetText($$StatusBar1, @TAB & $$y, 5)
Else
TCPShutdown() ; 停止 TCP 服务
_GUICtrlListView_SetItemText($$Listview1, $$i, "√", 7)
;------------------------------------------------------------------------------------------------------------------------------
;此处应该是更换图标
;GUICtrlSetImage($$i, "", "shell32.dll", 137)
;此处应该是更换背景颜色
;GUICtrlSetBkColor(_GUICtrlListView_GetItemParam($$Listview1, $$i), 0x2E8B57);更新颜色
;-------------------------------------------------------------------------------------------------------------------------------
_GUICtrlStatusBar_SetText($$StatusBar1, @TAB & $$x, 3)
EndIf
Next
_GUICtrlStatusBar_SetText($$StatusBar1, "总共" & $$cs & "台设备", 0)
_GUICtrlStatusBar_SetText($$StatusBar1, "", 1)
_ZenLxie()
updataa()
EndSwitch
WEnd
Func _ZenLxie();更新表中的数据记录
Local $$adTablea = "Radmin"
Local$$h7, $$z = 0;, $$id, $$y = 1, $$z = 1
$$cont = _GUICtrlListView_GetItemCount($$Listview1);取得数组的行列数
$$h7 = ""
For $$id = 0 To $$cont - 1
$$str = _GUICtrlListView_GetItemTextArray($$Listview1, $$id);列表项目的循环
$$h7 = $$str
$$addfld = ObjCreate("ADODB.Connection")
$$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $$DBName & ";Jet Oledb:Database Password=" & $$DBPswd)
$$addfld.ActiveConnection = $$addfld
$$addfld.execute("update " & $$adTablea & " setAA='" & $$h7 & "' WHERE id" & " = " & $$id)
$$z += 1
Next
$$addfld.close
MsgBox(0, '提示', $$z&" = " &$$h7, 1)
EndFunc ;==>_ZenLxie
Func updataa()
Local $$a = 0, $$b = 0, $$aa = 0
Local $$socket, $$adTablea = "Radmin"
GUICtrlSendMsg($$Listview1, $$LVM_DELETEALLITEMS, 0, 0)
$$addfld = ObjCreate("ADODB.Connection")
$$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $$DBName & ";Jet Oledb:Database Password=" & $$DBPswd)
$$array = $$addfld.Execute("SELECT * FROM " & $$adTablea).GetRows
$$RS = ObjCreate("ADODB.Recordset")
$$RS.ActiveConnection = $$addfld
$$RS.open("SELECT COUNT(*) FROM Radmin");
While (Not $$RS.eof And Not $$RS.bof);
$$P = $$RS.Fields(0).value
$$RS.movenext;
WEnd;
$$RS.close;
;_GUICtrlListView_AddArray($$Listview1, $$array)
Dim $$APP[$$P]
$$i = 0
$$addfld = ObjCreate("ADODB.Connection")
$$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $$DBName & ";Jet Oledb:Database Password=" & $$DBPswd)
$$RS = ObjCreate("ADODB.Recordset")
$$RS.ActiveConnection = $$addfld
$$RS.open("SELECT* fromRadmin");
While (Not $$RS.eof And Not $$RS.bof);
$$APP[$$i] = $$RS.Fields(0).value
$$APP[$$i] = $$RS.Fields(1).value
$$APP[$$i] = $$RS.Fields(2).value
$$APP[$$i] = $$RS.Fields(3).value
$$APP[$$i] = $$RS.Fields(4).value
$$APP[$$i] = $$RS.Fields(5).value
$$APP[$$i] = $$RS.Fields(6).value
$$i = $$i + 1
$$RS.movenext;
WEnd;
$$RS.close;
For $$x = 0 To $$P - 1
_GUICtrlListView_AddItem($$Listview1, $$APP[$$x], 0, -1)
_GUICtrlListView_AddSubItem($$Listview1, $$x, $$APP[$$x], 1, 0)
_GUICtrlListView_AddSubItem($$Listview1, $$x, $$APP[$$x], 2, -1)
_GUICtrlListView_AddSubItem($$Listview1, $$x, $$APP[$$x], 3, -1)
_GUICtrlListView_AddSubItem($$Listview1, $$x, $$APP[$$x], 4, -1)
_GUICtrlListView_AddSubItem($$Listview1, $$x, "******", 5, -1);"******",
If $$APP[$$x] = "×" Then
$$a += 1
$$b = 1
Else;If $$ad = "√" Then
$$aa += 1
$$b = 2
EndIf
_GUICtrlListView_AddSubItem($$Listview1, $$x, $$APP[$$x], 7, $$b)
Next
_GUICtrlStatusBar_SetText($$StatusBar1, @TAB & $$aa, 3)
_GUICtrlStatusBar_SetText($$StatusBar1, @TAB & $$a, 5)
_GUICtrlListView_RegisterSortCallBack($$Listview1)
_GUICtrlListView_SortItems($$Listview1, 0);以ID排序
_GUICtrlListView_SortItems($$Listview1, GUICtrlGetState($$Listview1))
_GUICtrlListView_UnRegisterSortCallBack($$Listview1)
EndFunc ;==>updataa
Func updata()
GUICtrlSendMsg($$Listview1, $$LVM_DELETEALLITEMS, 0, 0)
$$addfld = ObjCreate("ADODB.Connection")
$$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $$DBName & ";Jet Oledb:Database Password=" & $$DBPswd)
$$RS = ObjCreate("ADODB.Recordset")
$$RS.ActiveConnection = $$addfld
$$RS.open("SELECT COUNT(*) FROM Radmin");
While (Not $$RS.eof And Not $$RS.bof);
$$P = $$RS.Fields(0).value
$$RS.movenext;
WEnd;
$$RS.close;
Dim $$APP[$$P]
$$i = 0
$$addfld = ObjCreate("ADODB.Connection")
$$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $$DBName & ";Jet Oledb:Database Password=" & $$DBPswd)
$$RS = ObjCreate("ADODB.Recordset")
$$RS.ActiveConnection = $$addfld
$$RS.open("SELECT* fromRadmin");
While (Not $$RS.eof And Not $$RS.bof);
$$APP[$$i] = $$RS.Fields(0).value
$$APP[$$i] = $$RS.Fields(1).value
$$APP[$$i] = $$RS.Fields(2).value
$$APP[$$i] = $$RS.Fields(3).value
$$APP[$$i] = $$RS.Fields(4).value
$$APP[$$i] = $$RS.Fields(5).value
$$i = $$i + 1
$$RS.movenext;
WEnd;
$$RS.close;
For $$x = 0 To $$P - 1
_GUICtrlListView_AddItem($$Listview1, $$APP[$$x], 0, -1)
_GUICtrlListView_AddSubItem($$Listview1, $$x, $$APP[$$x], 1, 0)
_GUICtrlListView_AddSubItem($$Listview1, $$x, $$APP[$$x], 2, -1)
_GUICtrlListView_AddSubItem($$Listview1, $$x, $$APP[$$x], 3, -1)
_GUICtrlListView_AddSubItem($$Listview1, $$x, $$APP[$$x], 4, -1)
_GUICtrlListView_AddSubItem($$Listview1, $$x, "******", 5, -1);"******",
Next
_GUICtrlListView_RegisterSortCallBack($$Listview1)
_GUICtrlListView_SortItems($$Listview1, 0);以ID排序
_GUICtrlListView_SortItems($$Listview1, GUICtrlGetState($$Listview1))
_GUICtrlListView_UnRegisterSortCallBack($$Listview1)
EndFunc ;==>updata
Func _SetIcon($$hWnd, $$sFile, $$iIndex = 0, $$nAlign = 0, $$iWidth = 20, $$iHeight = 20) ;控件句柄, 图标图像的路径, 图标索引, 图标在控件中的位置, 图标宽度, 图标高度
$$hImage1 = _GUIImageList_Create($$iWidth, $$iHeight, 5, 1, 0) ;创建图像列表控件
_GUIImageList_AddIcon($$hImage1, $$sFile, $$iIndex, True) ;向图像列表添加图标
_GUICtrlButton_SetImageList($$hWnd, $$hImage1, $$nAlign) ;分配一个图像列表到按钮控件,$$nAlign 是图标位置参数
EndFunc ;==>_SetIcon
Func WM_NOTIFY($$hWnd, $$iMsg, $$iwParam, $$ilParam)
#forceref $$hWnd, $$iMsg, $$iwParam
Local $$iColumn = GUICtrlGetState($$Listview1) + 1
;Local $$SList1 = GUICtrlRead($$BInput1)
Local $$hWndListView1 = $$hListview1, $$iColumn = 1
If Not IsHWnd($$hListview1) Then $$hWndListView1 = GUICtrlGetHandle($$hListview1)
Local $$tNMHDR = DllStructCreate($$tagNMHDR, $$ilParam)
Local $$hWndFrom = HWnd(DllStructGetData($$tNMHDR, 'hWndFrom'))
Local $$iCode = DllStructGetData($$tNMHDR, 'Code')
Switch $$hWndFrom
Case $$hListview1;$$hWndListView1;$$hListView1
Switch $$iCode
Case $$NM_CLICK ;= -2
Global $$aHit = _GUICtrlListView_SubItemHitTest($$hListview1)
Local $$tInfo = DllStructCreate($$tagNMITEMACTIVATE, $$ilParam)
Local $$iIndex = DllStructGetData($$tInfo, 'Index')
Local $$iSub = DllStructGetData($$tInfo, 'SubItem')
$$index1 = _GUICtrlListView_GetSelectedIndices($$hListview1)
If $$index1 <> "" Then
Local $$idd = DllStructGetData($$tInfo, "Index")
;GUICtrlSetData($$iInput1, $$idd)
;GUICtrlSetData($$iInput4, $$idd)
Local $$sText
;$$idd= GUICtrlRead($$H)
$$aItem = _GUICtrlListView_GetItemTextArray($$Listview1, $$idd)
For $$i = 1 To $$aItem
$$sText &= $$aItem[$$i] & ",";& @CRLF
Next
MsgBox(0, "", $$sText)
Else
;MsgBox(0, "", "你点了空白栏", 1)
EndIf
Case -12;$$NM_CUSTOMDRAW
;If GUICtrlRead($$Checkboxg) = $$GUI_CHECKED Then
Local $$tInfo = DllStructCreate($$tagNMITEMACTIVATE, $$ilParam)
Local $$tCustDraw = DllStructCreate($$tagNMLVCUSTOMDRAW, $$ilParam)
Local $$iDrawStage = DllStructGetData($$tCustDraw, "dwDrawStage")
If $$iDrawStage = $$CDDS_PREPAINT Then Return $$CDRF_NOTIFYITEMDRAW
If $$iDrawStage = $$CDDS_ITEMPREPAINT Then Return $$CDRF_NOTIFYSUBITEMDRAW
Local $$iItem = DllStructGetData($$tCustDraw, "dwItemSpec")
Local $$iSubItem = DllStructGetData($$tCustDraw, "iSubItem")
Local $$FTxt2 = "×"
Local $$FTxt1 = "√"
Local $$FTxt3 = "00";"******";
Local $$sExt11 = $$FTxt1 & "|" & $$FTxt1
Local $$idd = DllStructGetData($$tInfo, "Index")
$$aItem = _GUICtrlListView_GetItemTextArray($$Listview1, $$idd)
For $$i = 1 To $$aItem
Local $$aa = _GUICtrlListView_GetItemText($$hWndListView1, $$iItem, $$i)
If StringRegExp($$aa, '(?mi)^\h*(' & $$sExt11 & ")$$") Then
$$iColor = RGB2BGR(0x0000FF)
$$iColorBk1 = RGB2BGR(0xFFFF00);(0xC0E0FF)
DllStructSetData($$tCustDraw, "clrText", $$iColor)
DllStructSetData($$tCustDraw, "clrTextBk", $$iColorBk1)
EndIf
Next
EndSwitch
EndSwitch
Return $$GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Func RGB2BGR($$iColor)
Return BitAND(BitShift(String(Binary($$iColor)), 8), 0xFFFFFF)
EndFunc ;==>RGB2BGR
chzj589
发表于 2023-11-2 10:12:17
xuanniao110 发表于 2023-11-2 09:20
不变色,算了
上面的方法是:
1:数据库增加一列。己上传。你原有的代码不变
2:读取<在线><离线>显示列表后写入新增的数据库
3:重新读取数据库
xuanniao110
发表于 2023-11-2 11:52:44
chzj589 发表于 2023-11-2 10:12
上面的方法是:
1:数据库增加一列。己上传。你原有的代码不变
2:读取<在线>显示列表后写入新增的数 ...
这个我试过了,不行,依然还是变不了色的,
chzj589
发表于 2023-11-2 12:37:36
xuanniao110 发表于 2023-11-2 11:52
这个我试过了,不行,依然还是变不了色的,
用我发的代码与数据库你有试过?
那我为何可以?
xuanniao110
发表于 2023-11-2 15:20:52
chzj589 发表于 2023-11-2 12:37
用我发的代码与数据库你有试过?
那我为何可以?
这真不晓得了,我把代码全弄上来
chzj589
发表于 2023-11-2 16:16:31
本帖最后由 chzj589 于 2023-11-2 16:18 编辑
xuanniao110 发表于 2023-11-2 15:20
这真不晓得了,我把代码全弄上来
问题还是读取网络连接,列表改色可以实现
chzj589
发表于 2023-11-2 16:41:03
xuanniao110 发表于 2023-11-2 15:20
这真不晓得了,我把代码全弄上来
你能运行判断是否在线或离线吗?
如能把在线的地址写入INI配置文件
如:
1=172.16.100.143
2=172.16.100.158
这样也可以读取INI配置文件将列表改色
xuanniao110
发表于 2023-11-2 23:53:46
本帖最后由 xuanniao110 于 2023-11-2 23:54 编辑
chzj589 发表于 2023-11-2 16:41
你能运行判断是否在线或离线吗?
如能把在线的地址写入INI配置文件
如:
我的就只有名称,在线,这两列变色,我win11x64,我在想办法试着不用数据库,用ini来存取数据