J'ai un souci avec l'événement AfterLabelEdit d'un contrôle ListView.
Ce que je fais dans le code :
En fait lorsque que je clique sur le radio lockage des fichiers, la ListView devient accessible, je peux alors ajouter autant d'extension que je veux (via le bouton Ajouter), à ce niveau tout va bien.
Ce que je voudrais faire c'est juste contrôler la saisie faite dans l'événement AfterLabelEdit. Le souci c'est que je ne récupère pas la totalité du champs saisie mais seulement le 1er caractère.
Je dois faire une boulette quelque part ...
Voici un bout de code de test :
► Afficher le textePb ListView AfterLabelEdit
Code : Tout sélectionner
; testBis
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Include <EncryptString.au3>
#include <array.au3>
#include <GuiStatusBar.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <ImageListConstants.au3>
#include <ListViewConstants.au3>
#include <WinAPI.au3>
Global const $Title = "TopGesVersions 1.0.01"
Global Const $KeyInstall = "HKEY_LOCAL_MACHINE\SOFTWARE\GesSources\Parameters"
Global Const $KeyExtens = "HKEY_LOCAL_MACHINE\SOFTWARE\GesSources\Extensions"
Global Const $KeyUser = "HKEY_LOCAL_MACHINE\SOFTWARE\GesSources\Users"
Global Const $KeyPassWord = "HKEY_LOCAL_MACHINE\SOFTWARE\GesSources\PassWords"
Global Const $PassLevel = 4
Global const $KEY_ESCAPE = -3
Global $Exit = False
Global $Us, $Pwd, $nMsg, $BtAdd, $BtDel, $RootFolder, $BtEnd
Global $IsAdmin = False
Global $Password, $WorkFld, $BtFolder, $User, $Stb, $LstV
Global $Users[1][3] ;Array Users = éléments (User / Passwrod / IsAdmin)
Global $UserCount = 0
Global $sKey = "TataYoyo"
Global $GUIuser, $GUIoptions
Global $Ind
SendOptions()
Func SendOptions($DefDir = '', $DefLckFld = True, $ArrExt = '')
Opt("GUIOnEventMode", 1)
$GUIoptions = GUICreate($Title, 340, 320, 196, 123)
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
; GuiSetIcon(@ScriptDir & "\icones\GestionVersion.ico")
$Group1 = GUICtrlCreateGroup(" Dossier de projets ", 5, 3, 329, 65)
; $ImgL = _GUIImageList_Create(16, 16, 5)
; _GUIImageList_AddIcon($ImgL, @ScriptDir & "\Icones\Burn.ico", 0, True)
$WorkFld = GUICtrlCreateInput("blablablabla", 13, 19, 313, 21)
GUICtrlSetOnEvent($WorkFld, "_WorkFldChange")
If $DefDir <> "" Then GUICtrlSetData($WorkFld, $DefDir)
GUICtrlSetState($WorkFld, $GUI_DISABLE)
$BtFolder = GUICtrlCreateButton("Parcourir", 253, 43, 73, 20, $WS_GROUP)
GUICtrlSetOnEvent($BtFolder, "_BtFolderChange")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Stb = _GUICtrlStatusBar_Create($GUIoptions)
_GUICtrlStatusBar_SetSimple($Stb)
_GUICtrlStatusBar_SetText($Stb, "A vous de jouer ...")
_GUICtrlStatusBar_SetMinHeight($Stb, 17)
Global $Group2 = GUICtrlCreateGroup(" Options de lockage ", 8, 72, 321, 195)
Global $RdFolderLock = GUICtrlCreateRadio("Lockage des dossiers", 25, 100, 121, 17)
GUICtrlSetOnEvent($RdFolderLock, "_RdFolderLockClic")
Global $RdLockFile = GUICtrlCreateRadio("Lockage des fichiers", 169, 100, 121, 17)
GUICtrlSetOnEvent($RdLockFile, "_RdLockFileClic")
$LstV = GUICtrlCreateListView("", 24, 144, 289, 89, BitOR($LVS_LIST,$LVS_EDITLABELS,$LVS_SINGLESEL,$LVS_SHOWSELALWAYS))
; _GUICtrlListView_SetImageList($LstV, $ImgL, 1)
_GUICtrlListView_SetColumnWidth($LstV, 0, 93)
_GUICtrlListView_SetColumnWidth($LstV, 1, 93)
_GUICtrlListView_SetColumnWidth($LstV, 2, 93)
Global $BtAdd = GUICtrlCreateButton("Ajouter", 176, 240, 65, 20, $WS_GROUP)
GUICtrlSetOnEvent($BtAdd, "_BtAddClic")
Global $BtDel = GUICtrlCreateButton("Supprimer", 248, 240, 65, 20, $WS_GROUP)
GUICtrlSetOnEvent($BtDel, "_BtDelClic")
Global $Label1 = GUICtrlCreateLabel("Extensions", 24, 128, 70, 18)
GUICtrlSetFont(-1, 9, 800, 0, "Tahoma")
GUICtrlSetColor(-1, 0x000080)
If $DefLckFld Then
GUICtrlSetState($RdFolderLock, $GUI_CHECKED)
GUICtrlSetState($LstV, $GUI_DISABLE)
GUICtrlSetState($BtAdd, $GUI_DISABLE)
GUICtrlSetState($BtDel, $GUI_DISABLE)
Else
GUICtrlSetState($RdLockFile, $GUI_CHECKED)
GUICtrlSetState($LstV, $GUI_ENABLE)
GUICtrlSetState($BtAdd, $GUI_ENABLE)
GUICtrlSetState($BtDel, $GUI_ENABLE)
EndIf
If IsArray($ArrExt) Then
Local $K
For $K = 0 To ubound($ArrExt)-1
If $ArrExt[$K] <> "" Then
_GUICtrlListView_AddItem($LstV, $ArrExt[$K], -1)
endif
Next
EndIf
$Exit = False
GUICtrlCreateGroup("", -99, -99, 1, 1)
$BtEnd = GUICtrlCreateButton("&Fin", 245, 271, 81, 20, $WS_GROUP)
GUICtrlSetOnEvent($BtEnd, "_End")
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
While True
If $Exit then ExitLoop
Sleep(10)
WEnd
GUIDelete($GUIoptions)
Return
EndFunc
Func SpecialEvents()
Select
Case @GUI_CtrlId = $GUI_EVENT_CLOSE
_End()
Exit
EndSelect
EndFunc
Func _End()
Local $J
; For $J = 0 To _GUICtrlListView_GetItemCount($LstV)
; next
$Exit = True
EndFunc
Func _BtDelClic()
$Ind = _GUICtrlListView_GetSelectedIndices($LstV)
If $Ind <> "" Then
_GUICtrlListView_DeleteItemsSelected(GUICtrlGetHandle($LstV))
EndIf
_GUICtrlStatusBar_SetText($Stb, "Extension supprimée " & $Ind)
EndFunc
Func _BtAddClic()
$Ind = _GUICtrlListView_AddItem($LstV, "", -1)
_GUICtrlListView_EditLabel($LstV, $Ind)
; _GUICtrlStatusBar_SetText($Stb, "Saisir l'extension sur 3 caractères")
EndFunc
Func _RdLockFileClic()
GUICtrlSetState($LstV, $GUI_ENABLE)
GUICtrlSetState($BtAdd, $GUI_ENABLE)
GUICtrlSetState($BtDel, $GUI_ENABLE)
RegWrite($KeyInstall, "IsFolderLock", "REG_SZ", False)
_GUICtrlStatusBar_SetText($Stb, "Lockage par fichier")
EndFunc
Func _RdFolderLockClic()
GUICtrlSetState($LstV, $GUI_DISABLE)
GUICtrlSetState($BtAdd, $GUI_DISABLE)
GUICtrlSetState($BtDel, $GUI_DISABLE)
RegWrite($KeyInstall, "IsFolderLock", "REG_SZ", True)
_GUICtrlStatusBar_SetText($Stb, "Lockage par dossier")
EndFunc
Func _WorkFldChange()
If FolderChoice($WorkFld) Then
GUICtrlSetData($WorkFld, $RootFolder)
EndIf
EndFunc
Func _BtFolderChange()
If FolderChoice() Then
GUICtrlSetData($WorkFld, $RootFolder)
EndIf
EndFunc
Func FolderChoice($ValDef = '')
If $ValDef = "" Then
$Ret = FileSelectFolder("Choix du projet à maintenir", @DesktopDir, 2)
Else
$Ret = $ValDef
EndIf
If $Ret = "" Or Not FileExists($Ret) Then
_GUICtrlStatusBar_SetText($Stb, "Le choix du dossier est obligatoire")
GUICtrlSetState($BtFolder, $GUI_FOCUS)
Return False
endif
RegWrite($KeyInstall, "DefaultFolder", "REG_SZ", $Ret)
$RootFolder = $Ret
Return True
EndFunc
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
$hWndListView = $LstV
If Not IsHWnd($LstV) Then $hWndListView = GUICtrlGetHandle($LstV)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListView
Switch $iCode
Case $LVN_BEGINLABELEDITA, $LVN_BEGINLABELEDITW
$tInfo = DllStructCreate($tagNMLVDISPINFO, $ilParam)
Return False
Case $LVN_DELETEITEM
$tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
Case $LVN_ENDLABELEDITA, $LVN_ENDLABELEDITW
$tInfo = DllStructCreate($tagNMLVDISPINFO, $ilParam)
Local $tBuffer = DllStructCreate("char Text[" & DllStructGetData($tInfo, "TextMax") & "]", DllStructGetData($tInfo, "Text"))
ConsoleWrite("$LVN_ENDLABELEDIT" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode & @LF & _
"-->Mask:" & @TAB & DllStructGetData($tInfo, "Mask") & @LF & _
"-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @LF & _
"-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF & _
"-->State:" & @TAB & DllStructGetData($tInfo, "State") & @LF & _
"-->StateMask:" & @TAB & DllStructGetData($tInfo, "StateMask") & @LF & _
"-->Text:" & @TAB & DllStructGetData($tBuffer, "Text") & @LF & _
"-->TextMax:" & @TAB & DllStructGetData($tInfo, "TextMax") & @LF & _
"-->Image:" & @TAB & DllStructGetData($tInfo, "Image") & @LF & _
"-->Param:" & @TAB & DllStructGetData($tInfo, "Param") & @LF & _
"-->Indent:" & @TAB & DllStructGetData($tInfo, "Indent") & @LF & _
"-->GroupID:" & @TAB & DllStructGetData($tInfo, "GroupID") & @LF & _
"-->Columns:" & @TAB & DllStructGetData($tInfo, "Columns") & @LF & _
"-->pColumns:" & @TAB & DllStructGetData($tInfo, "pColumns"))
If StringLen(DllStructGetData($tBuffer, "Text")) Then Return True
Case $NM_CLICK
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
Case $NM_SETFOCUS
Case $NM_RETURN
Case $NM_KILLFOCUS
Case $LVN_COLUMNCLICK
Case Else
_GUICtrlStatusBar_SetText(0, "", "$iCode=" & $iCode)
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc

