Je sais faire les listview avec des checkbox.
Le souci : j'aimerais qu'une seule case soit cochée.
Plus précisément, je ne veux pas qu'on puisse cocher plusieurs cases à la fois.
En gros, si une case est cochée, les autres sont automatiquement décochées.
Est-ce possible ?
Mon script est déjà codé.
Je vous joins un script minimaliste :
► Afficher le textecode
Code : Tout sélectionner
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
Global $Form1 = GUICreate("Form1", 466, 120, 192, 124)
$DNS_LV = GUICtrlCreateListView("test1|test2|test3",10,10,400,100, -1, $LVS_EX_CHECKBOXES + $WS_EX_CLIENTEDGE + $LVS_EX_GRIDLINES)
GUICtrlCreateListViewItem("1|2|3",$DNS_LV)
GUICtrlCreateListViewItem("4|5|6",$DNS_LV)
GUICtrlCreateListViewItem("7|8|9",$DNS_LV)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
► Afficher le textecode
Code : Tout sélectionner
#include <file.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>
$FMDNS_Dir = @TempDir & "\FindMyDNS"
DirRemove($FMDNS_Dir, 1)
DirCreate($FMDNS_Dir)
;~ _ListDNS()
Global $Form1 = GUICreate("Form1", 900, 400, 192, 124)
$DNS_LV = GUICtrlCreateListView("Clé|Interface (CLSID)|NameServer/DhcpNameServer",10,50,400,200, -1, $LVS_EX_CHECKBOXES + $WS_EX_CLIENTEDGE + $LVS_EX_GRIDLINES)
_ListDNS()
GUICtrlSendMsg($DNS_LV, $LVM_SETCOLUMNWIDTH, 0, $LVSCW_AUTOSIZE)
GUICtrlSendMsg($DNS_LV, $LVM_SETCOLUMNWIDTH, 1, $LVSCW_AUTOSIZE)
GUICtrlSendMsg($DNS_LV, $LVM_SETCOLUMNWIDTH, 2, $LVSCW_AUTOSIZE)
$width1 = _GUICtrlListView_GetColumnWidth($DNS_LV,0)
$width2 = _GUICtrlListView_GetColumnWidth($DNS_LV,1)
$width3 = _GUICtrlListView_GetColumnWidth($DNS_LV,2)
_GUICtrlListView_SetColumnWidth($DNS_LV,0,$width1+10)
_GUICtrlListView_SetColumnWidth($DNS_LV,1,$width2+10)
_GUICtrlListView_SetColumnWidth($DNS_LV,2,$width3+10)
$width = $width1+$width2+$width3+30
WinMove($Form1,"",10,10,$width+30)
GUICtrlSetPos ( $DNS_LV, 10,50 ,$width)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func _ListDNS()
_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($DNS_LV))
$FileKeyInterfaces = $FMDNS_Dir & "\KeyInterfaces.txt"
$FileKeyInterfaces2 = $FMDNS_Dir & "\KeyInterfaces2.txt"
$kDNS1 = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces"
$kDNS2 = "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Tcpip\Parameters\Interfaces"
$kDNS3 = "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Services\Tcpip\Parameters\Interfaces"
Global $a = 1
$tFKI = FileOpen($FileKeyInterfaces, 2)
While 1
$KeyInterfaces = RegEnumKey($kDNS1, $a)
If $KeyInterfaces = "" Then
$a = 1
ExitLoop
EndIf
FileWriteLine($tFKI, $kDNS1 & "\" & $KeyInterfaces)
$a += 1
WEnd
While 1
$KeyInterfaces = RegEnumKey($kDNS2, $a)
If $KeyInterfaces = "" Then
$a = 1
ExitLoop
EndIf
FileWriteLine($tFKI, $kDNS2 & "\" & $KeyInterfaces)
$a += 1
WEnd
While 1
$KeyInterfaces = RegEnumKey($kDNS3, $a)
If $KeyInterfaces = "" Then
$a = 1
ExitLoop
EndIf
FileWriteLine($tFKI, $kDNS3 & "\" & $KeyInterfaces)
$a += 1
WEnd
FileClose($tFKI)
$tFKI2 = FileOpen($FileKeyInterfaces2, 2)
For $i = 1 To _FileCountLines($FileKeyInterfaces)
If RegRead(FileReadLine($FileKeyInterfaces, $i), "NameServer") <> "" Then FileWriteLine($tFKI2, FileReadLine($FileKeyInterfaces, $i) & "|" & RegRead(FileReadLine($FileKeyInterfaces, $i), "NameServer"))
If RegRead(FileReadLine($FileKeyInterfaces, $i), "DhcpNameServer") <> "" Then FileWriteLine($tFKI2, FileReadLine($FileKeyInterfaces, $i) & "|" & RegRead(FileReadLine($FileKeyInterfaces, $i), "DhcpNameServer"))
Next
FileWriteLine($tFKI2, "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" & "|" & "FAI" &"|"& RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters", "DhcpNameServer"))
FileClose($tFKI2)
_ReplaceStringInFile($FileKeyInterfaces2,$kDNS1&"\",$kDNS1&"|")
_ReplaceStringInFile($FileKeyInterfaces2,$kDNS2&"\",$kDNS2&"|")
_ReplaceStringInFile($FileKeyInterfaces2,$kDNS3&"\",$kDNS3&"|")
FileMove($FileKeyInterfaces2,$FileKeyInterfaces,1)
For $i = 1 to _FileCountLines($FileKeyInterfaces)
GUICtrlCreateListViewItem(FileReadLine($FileKeyInterfaces,$i),$DNS_LV)
Next
EndFuncMerci de m'éclairer ma petite lanterne.
++



