【已解决】$ListView1列表收到的信息先后显示顺序?
本帖最后由 mshuking 于 2015-7-16 13:34 编辑已解决$LVS_SORTDESCENDING$ListView1 = GUICtrlCreateListView("计算机|IP地址|时间|信息", 0, 0, 458, 414,$LVS_SORTDESCENDING)变
把时间最先的在下面,刚刚的时间 搞到上面 顺序由下而上 怎么写代码?谢谢#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
#Include <Date.au3>
$Form1 = GUICreate("测试服务端", 460, 444)
$ListView1 = GUICtrlCreateListView("计算机|IP地址|时间|信息", 0, 0, 458, 414,$LVS_SORTDESCENDING)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 100);调整宽度
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 100);调整宽度
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 100);调整宽度
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 100);调整宽度
GUICtrlSendMsg($ListView1, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES);设置表格边框
GUICtrlSetCursor(-1, 0);鼠标指针
$List = GUICtrlCreateContextMenu($ListView1)
$Cls = GUICtrlCreateMenuItem("清空数据", $List)
GUICtrlCreateMenuItem("", $List)
$Quit = GUICtrlCreateMenuItem("退出", $List)
GUISetState(@SW_SHOW)
TCPStartup(); 开始 TCP 服务
$ip = IniRead(@ScriptDir & '\configs.ini', 'Config', 'ServerIP', '192.168.0.7');从配置文件中读取IP
$port = IniRead(@ScriptDir & '\configs.ini', 'Config', 'ServerPort', '21991');从配置文件中读取端口
$tcpMainListen = TCPListen($ip, $port, 100);创建监听,用于接收数据
If $tcpMainListen = -1 Then
MsgBox(4096, '错误', '创建监听失败!')
Exit
EndIf
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE,$Quit
Exit
Case $Cls
GUICtrlSendMsg($ListView1, $LVM_DELETEALLITEMS, 0, 0)
EndSwitch
$tcpSocket = TCPAccept($tcpMainListen);接收客户端连接
If $tcpSocket <> -1 Then;客户端连接成功
While 1
$TcpRecvData = TCPRecv($tcpSocket, 2048, 1);接收客户端发送的数据
If @error Then ExitLoop ;如果接收信息出现错误,则退出循环.
If $TcpRecvData <> '' Then
$TcpRecvData = GUICtrlCreateListViewItem(BinaryToString($TcpRecvData, 4), $ListView1);将信息写入到$listview1控件
;这里如何写 下面语音才生效
_PLAYJH($Jihao)
ExitLoop
EndIf
WEnd
EndIf
WEnd
;=============================================================================
;语音叫号
Func _PLAYJH($Jihao)
$JihaoHQ = StringRight($Jihao,3)
$FenGe = StringSplit($JihaoHQ,"")
SoundPlay("woman\fw.wav")
Sleep(2000)
If $Jihao < 1000 And $Jihao > 99 Then
SoundPlay("woman\"&$FenGe&".wav")
Sleep(500)
SoundPlay("woman\100.wav")
If $FenGe <> 0 Then
Sleep(500)
SoundPlay("woman\"&$FenGe&".wav")
Sleep(500)
SoundPlay("woman\10.wav")
ElseIf $FenGe = 0 And $FenGe <> 0 Then
Sleep(500)
SoundPlay("woman\"&$FenGe&".wav")
EndIf
If $FenGe <> 0 Then
Sleep(500)
SoundPlay("woman\"&$FenGe&".wav")
EndIf
EndIf
If $Jihao < 100 And $Jihao > 9 Then
$JihaoHQ = StringRight($strepl,2)
$FenGe = StringSplit($JihaoHQ,"")
SoundPlay("woman\"&$FenGe&".wav")
Sleep(500)
SoundPlay("woman\10.wav")
If $FenGe <> 0 Then
Sleep(500)
SoundPlay("woman\"&$FenGe&".wav")
EndIf
EndIf
If $Jihao < 10 And $Jihao > 0 Then
$JihaoHQ = StringRight($strepl,1)
SoundPlay("woman\"&$JihaoHQ&".wav")
EndIf
Sleep(500)
SoundPlay("woman\hao.wav")
Sleep(500)
SoundPlay("woman\dc.wav")
EndFunc#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$Form2 = GUICreate("语音呼叫", 273, 249)
$Button1 = GUICtrlCreateButton("呼叫网管", 16, 24, 243, 41)
$Button2 = GUICtrlCreateButton("呼叫技术员", 16, 88, 241, 41)
$Button3 = GUICtrlCreateButton("呼叫服务员", 16, 152, 243, 41)
GUISetState(@SW_SHOW)
TCPStartup(); 开始 TCP 服务; 开始 TCP 服务
$ip = IniRead(@ScriptDir & '\wglm.ini', 'Config', 'ServerIP', @IPAddress1);从配置文件中读取IP
$port = IniRead(@ScriptDir & '\wglm.ini', 'Config', 'ServerPort', '21991');从配置文件中读取端口
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1;呼叫网管
_Callinfo('呼叫网管')
Case $Button2;呼叫技术员
_Callinfo('呼叫技术员')
Case $Button3;呼叫服务员
_Callinfo('叫服务员')
EndSwitch
WEnd
;呼叫信息
Func _Callinfo($CallInfo)
$tcpMainSocket = TCPConnect($ip, $port);连接服务端
If $tcpMainSocket = -1 Then
MsgBox(64, '错误', '连接到服务端失败!',2)
Else
TCPSend($tcpMainSocket, StringToBinary(@ComputerName & '|' & @HOUR & ":" & @MIN & ":" & @SEC & '|' & $CallInfo & "|" & @IPAddress1, 4))
EndIf
EndFunc ;==>_Callinfo 需要修改哪里 知道的说下 #include <GUIConstantsEx.au3>
#include <GuiListView.au3>
GUICreate("ListViewTest", 300, 200)
$hListView = GUICtrlCreateListView("列1|列2|列3", 10, 10)
_GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_SUBITEMIMAGES))
GUICtrlCreateListViewItem("ABC|666|流氓发", $hListView)
GUICtrlCreateListViewItem("DEF|444|闷骚发", $hListView)
GUICtrlCreateListViewItem("EFG|555|牛逼发", $hListView)
GUICtrlCreateListViewItem("CDE|777|人气发", $hListView)
GUISetState()
_GUICtrlListView_RegisterSortCallBack($hListView)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit (_GUICtrlListView_UnRegisterSortCallBack($hListView))
Case $hListView
_GUICtrlListView_SortItems($hListView, GUICtrlGetState($hListView))
EndSwitch
WEnd
学习了,_GUICtrlListView_SortItems
启动列表视图回叫排序, 并设置标题中的箭头. 加个排序函数! 回复 3# haijie1223
谢谢分享。。。。。
我要的是自动按时间排序,不是手动点来排序 回复 5# f4李文杨
自动排序函数!怎么加? #include <GUIConstantsEx.au3>
#include <GuiListView.au3>
GUICreate("ListViewTest", 300, 200)
$hListView = GUICtrlCreateListView(" 客户机 |播放时间|这都是你名字", 10, 10,280)
_GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_SUBITEMIMAGES))
GUICtrlCreateListViewItem("你他么伸手党|250:250:250|屌丝男", $hListView)
GUICtrlCreateListViewItem("你他么屌丝男|13:13:13|伸手党", $hListView)
GUICtrlCreateListViewItem("你他么傻波一|2:2:250|臭屎头", $hListView)
GUICtrlCreateListViewItem("你他么臭屎头|250:13:2|傻波一", $hListView)
GUISetState()
_GUICtrlListView_RegisterSortCallBack($hListView)
_GUICtrlListView_SortItems($hListView, 1)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit (_GUICtrlListView_UnRegisterSortCallBack($hListView))
EndSwitch
WEnd 本帖最后由 mshuking 于 2015-7-12 21:14 编辑
回复 8# haijie1223
我测试了 很失败#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
#Include <Date.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
$Form1 = GUICreate("测试服务端", 460, 444)
$ListView1 = GUICtrlCreateListView("计算机|IP地址|时间|信息", 0, 0, 458, 414)
_GUICtrlListView_SetExtendedListViewStyle($ListView1, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_SUBITEMIMAGES))
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 100);调整宽度
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 100);调整宽度
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 100);调整宽度
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 100);调整宽度
;GUICtrlSendMsg($ListView1, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES);设置表格边框
GUICtrlSetCursor(-1, 0);鼠标指针
$List = GUICtrlCreateContextMenu($ListView1)
$Cls = GUICtrlCreateMenuItem("清空数据", $List)
GUICtrlCreateMenuItem("", $List)
$Quit = GUICtrlCreateMenuItem("退出", $List)
GUISetState(@SW_SHOW)
_GUICtrlListView_RegisterSortCallBack($ListView1)
_GUICtrlListView_SortItems($ListView1, 1)
TCPStartup(); 开始 TCP 服务
$ip = IniRead(@ScriptDir & '\configs.ini', 'Config', 'ServerIP', '127.0.0.1');从配置文件中读取IP
$port = IniRead(@ScriptDir & '\configs.ini', 'Config', 'ServerPort', '21991');从配置文件中读取端口
$tcpMainListen = TCPListen($ip, $port, 100);创建监听,用于接收数据
If $tcpMainListen = -1 Then
MsgBox(4096, '错误', '创建监听失败!')
Exit
EndIf
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE,$Quit
Exit(_GUICtrlListView_UnRegisterSortCallBack($ListView1))
Case $Cls
GUICtrlSendMsg($ListView1, $LVM_DELETEALLITEMS, 0, 0)
EndSwitch
$tcpSocket = TCPAccept($tcpMainListen);接收客户端连接
If $tcpSocket <> -1 Then;客户端连接成功
While 1
$TcpRecvData = TCPRecv($tcpSocket, 2048, 1);接收客户端发送的数据
If @error Then ExitLoop ;如果接收信息出现错误,则退出循环.
If $TcpRecvData <> '' Then
$TcpRecvData = GUICtrlCreateListViewItem(BinaryToString($TcpRecvData, 4), $ListView1);将信息写入到$listview1控件
;这里如何写 下面语音才生效
;_PLAYJH($Jihao)
ExitLoop
EndIf
WEnd
EndIf
WEnd#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$Form2 = GUICreate("语音呼叫", 273, 249)
$Button1 = GUICtrlCreateButton("呼叫网管", 16, 24, 243, 41)
$Button2 = GUICtrlCreateButton("呼叫技术员", 16, 88, 241, 41)
$Button3 = GUICtrlCreateButton("呼叫服务员", 16, 152, 243, 41)
GUISetState(@SW_SHOW)
TCPStartup(); 开始 TCP 服务; 开始 TCP 服务
$ip = IniRead(@ScriptDir & '\configs.ini', 'Config', 'ServerIP', "127.0.0.1");从配置文件中读取IP
$port = IniRead(@ScriptDir & '\configs.ini', 'Config', 'ServerPort', '21991');从配置文件中读取端口
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1;呼叫网管
_Callinfo('呼叫网管')
Case $Button2;呼叫技术员
_Callinfo('呼叫技术员')
Case $Button3;呼叫服务员
_Callinfo('叫服务员')
EndSwitch
WEnd
;呼叫信息
Func _Callinfo($CallInfo)
$tcpMainSocket = TCPConnect($ip, $port);连接服务端
If $tcpMainSocket = -1 Then
MsgBox(64, '错误', '连接到服务端失败!',2)
Else
TCPSend($tcpMainSocket, StringToBinary(@ComputerName & '|' & @HOUR & ":" & @MIN & ":" & @SEC & '|' & $CallInfo & "|" & @IPAddress1, 4))
EndIf
EndFunc ;==>_Callinfo 说点什么好,这个样式帮助中就有吧。#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
#Include <Date.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
$Form1 = GUICreate("测试服务端", 460, 444)
$ListView1 = GUICtrlCreateListView("计算机|IP地址|时间|信息", 0, 0, 458, 414,$LVS_SORTDESCENDING)
_GUICtrlListView_SetExtendedListViewStyle($ListView1, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_SUBITEMIMAGES))
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 100);调整宽度
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 100);调整宽度
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 100);调整宽度
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 100);调整宽度
;GUICtrlSendMsg($ListView1, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES);设置表格边框
GUICtrlSetCursor(-1, 0);鼠标指针
$List = GUICtrlCreateContextMenu($ListView1)
$Cls = GUICtrlCreateMenuItem("清空数据", $List)
GUICtrlCreateMenuItem("", $List)
$Quit = GUICtrlCreateMenuItem("退出", $List)
GUISetState(@SW_SHOW)
_GUICtrlListView_RegisterSortCallBack($ListView1)
;~ _GUICtrlListView_SortItems($ListView1, 1)
TCPStartup(); 开始 TCP 服务
$ip = IniRead(@ScriptDir & '\configs.ini', 'Config', 'ServerIP', '127.0.0.1');从配置文件中读取IP
$port = IniRead(@ScriptDir & '\configs.ini', 'Config', 'ServerPort', '21991');从配置文件中读取端口
$tcpMainListen = TCPListen($ip, $port, 100);创建监听,用于接收数据
If $tcpMainListen = -1 Then
MsgBox(4096, '错误', '创建监听失败!')
Exit
EndIf
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE,$Quit
Exit(_GUICtrlListView_UnRegisterSortCallBack($ListView1))
Case $Cls
GUICtrlSendMsg($ListView1, $LVM_DELETEALLITEMS, 0, 0)
EndSwitch
$tcpSocket = TCPAccept($tcpMainListen);接收客户端连接
If $tcpSocket <> -1 Then;客户端连接成功
While 1
$TcpRecvData = TCPRecv($tcpSocket, 2048, 1);接收客户端发送的数据
If @error Then ExitLoop ;如果接收信息出现错误,则退出循环.
If $TcpRecvData <> '' Then
$TcpRecvData = GUICtrlCreateListViewItem(BinaryToString($TcpRecvData, 4), $ListView1);将信息写入到$listview1控件
;这里如何写 下面语音才生效
;_PLAYJH($Jihao)
ExitLoop
EndIf
WEnd
EndIf
WEnd 回复 10# haijie1223
谢谢一下子明白了加这个就好$LVS_SORTDESCENDING
谢谢 回复 8# haijie1223
简单粗暴,解决了我排序的问题,之前排序一直有几行不按顺序站好,谢谢!
页:
[1]