Je cherche le moyen de trier des adresses IP pour les afficher dans une listview
► Afficher le texte
Code : Tout sélectionner
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIListView.au3>
Global $cListView, $fSortSense = False ; Set initial ascending sort
Example()
Func Example()
GUICreate("SimpleSort", 300, 300)
$cListView = GUICtrlCreateListView("TRI IP", 10, 10, 280, 240)
_GUICtrlListView_SetColumnWidth($cListView, 0, 260)
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")
GUICtrlCreateListViewItem("192.168.0.2", $cListView)
GUICtrlCreateListViewItem("192.168.10.1", $cListView)
GUICtrlCreateListViewItem("192.168.50.12", $cListView)
GUICtrlCreateListViewItem("192.0.0.252", $cListView)
GUICtrlCreateListViewItem("192.168.0.135", $cListView)
GUICtrlCreateListViewItem("192.168.0.60", $cListView)
GUICtrlCreateListViewItem("192.168.0.98", $cListView)
GUICtrlCreateListViewItem("192.168.0.207", $cListView)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
EndSwitch
WEnd
EndFunc ;==>Example
Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
#forceref $hWnd, $iMsg, $wParam
Local $hWndListView = $cListView
If Not IsHWnd($cListView) Then $hWndListView = GUICtrlGetHandle($cListView)
Local $tNMHDR = DllStructCreate($tagNMLISTVIEW, $lParam)
Local $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
Local $iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListView
Switch $iCode
Case $LVN_COLUMNCLICK ; A column was clicked
_GUICtrlListView_SimpleSort($hWndListView, $fSortSense, DllStructGetData($tNMHDR, "SubItem")) ; Sort direction for next sort toggled by default
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>_WM_NOTIFY
Merci de vos sugestions
A+
JL56