Démarre, sur place, l'édition du texte de l'élément spécifié
#include <GuiListView.au3>
_GUICtrlListView_EditLabel ( $hWnd, $iIndex )
$hWnd | ID/handle du contrôle |
$iIndex | Index, de base 0, de l'élémentà modifier |
Succès: | Retourne le handle du contrôle d'édition qui est utilisé pour modifier l'élément. |
Échec: | Retourne 0. |
Lorsque l'utilisateur termine ou annule l'édition, le contrôle d'édition est détruit et le handle n'est plus valide.
Vous pourriez créer un contrôle d'édition, et ne pas le détruire.
_GUICtrlListView_CancelEditLabel
#include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> Global $g_hListView, $g_idMemo Example() Func Example() Local $hGui, $hImage $hGui = GUICreate("ListView Edit Label", 400, 300, Default, Default, Default, $WS_EX_CLIENTEDGE) $g_hListView = _GUICtrlListView_Create($hGui, "", 2, 2, 394, 118, BitOR($LVS_EDITLABELS, $LVS_REPORT)) $g_idMemo = GUICtrlCreateEdit("", 2, 124, 396, 174, 0) GUISetState(@SW_SHOW) ; Charge les images $hImage = _GUIImageList_Create() _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($g_hListView, 0xFF0000, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($g_hListView, 0x00FF00, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($g_hListView, 0x0000FF, 16, 16)) _GUICtrlListView_SetImageList($g_hListView, $hImage, 1) ; Ajoute des colonnes _GUICtrlListView_InsertColumn($g_hListView, 0, "Column 1", 100) _GUICtrlListView_InsertColumn($g_hListView, 1, "Column 2", 100) _GUICtrlListView_InsertColumn($g_hListView, 2, "Column 3", 100) ; Ajoute des éléments _GUICtrlListView_AddItem($g_hListView, "Row 1: Col 1", 0) _GUICtrlListView_AddSubItem($g_hListView, 0, "Row 1: Col 2", 1) _GUICtrlListView_AddSubItem($g_hListView, 0, "Row 1: Col 3", 2) _GUICtrlListView_AddItem($g_hListView, "Row 2: Col 1", 1) _GUICtrlListView_AddSubItem($g_hListView, 1, "Row 2: Col 2", 1) _GUICtrlListView_AddItem($g_hListView, "Row 3: Col 1", 2) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") ; Edite l"étiquette de l'élément 0 avec délai limite Local $hEditLabel = _GUICtrlListView_EditLabel($g_hListView, 0) MemoWrite("Edit Label Handle = 0x" & Hex($hEditLabel) & " IsPtr = " & IsPtr($hEditLabel) & " IsHWnd = " & IsHWnd($hEditLabel)) ; Boucle jusqu'à ce que l'utilisateur quitte. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo $hWndListView = $g_hListView If Not IsHWnd($g_hListView) Then $hWndListView = GUICtrlGetHandle($g_hListView) $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $LVN_BEGINLABELEDITA, $LVN_BEGINLABELEDITW ; Démarre l'édition de l'étiquette de l'élément $tInfo = DllStructCreate($tagNMLVDISPINFO, $lParam) _DebugPrint("$LVN_BEGINLABELEDIT" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode & @CRLF & _ "-->Mask:" & @TAB & DllStructGetData($tInfo, "Mask") & @CRLF & _ "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _ "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _ "-->State:" & @TAB & DllStructGetData($tInfo, "State") & @CRLF & _ "-->StateMask:" & @TAB & DllStructGetData($tInfo, "StateMask") & @CRLF & _ "-->Image:" & @TAB & DllStructGetData($tInfo, "Image") & @CRLF & _ "-->Param:" & @TAB & DllStructGetData($tInfo, "Param") & @CRLF & _ "-->Indent:" & @TAB & DllStructGetData($tInfo, "Indent") & @CRLF & _ "-->GroupID:" & @TAB & DllStructGetData($tInfo, "GroupID") & @CRLF & _ "-->Columns:" & @TAB & DllStructGetData($tInfo, "Columns") & @CRLF & _ "-->pColumns:" & @TAB & DllStructGetData($tInfo, "pColumns")) Return False ; Permet à l'utilisateur de modifier l'étiquette ; Return True ; Empêche l'utilisateur de modifier l'étiquette Case $LVN_COLUMNCLICK ; Une colonne a été cliquée $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam) _DebugPrint("$LVN_COLUMNCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode & @CRLF & _ "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _ "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _ "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _ "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _ "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _ "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _ "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _ "-->Param:" & @TAB & DllStructGetData($tInfo, "Param")) ; Aucune valeur retournée Case $LVN_DELETEITEM ; Un élément est sur le point d'être supprimé $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam) _DebugPrint("$LVN_DELETEITEM" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode & @CRLF & _ "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _ "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _ "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _ "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _ "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _ "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _ "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _ "-->Param:" & @TAB & DllStructGetData($tInfo, "Param")) ; Aucune valeur retournée Case $LVN_ENDLABELEDITA, $LVN_ENDLABELEDITW ; La fin de l'édition de l'étiquette de l"élément $tInfo = DllStructCreate($tagNMLVDISPINFO, $lParam) Local $tBuffer = DllStructCreate("char Text[" & DllStructGetData($tInfo, "TextMax") & "]", DllStructGetData($tInfo, "Text")) _DebugPrint("$LVN_ENDLABELEDIT" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode & @CRLF & _ "-->Mask:" & @TAB & DllStructGetData($tInfo, "Mask") & @CRLF & _ "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _ "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _ "-->State:" & @TAB & DllStructGetData($tInfo, "State") & @CRLF & _ "-->StateMask:" & @TAB & DllStructGetData($tInfo, "StateMask") & @CRLF & _ "-->Text:" & @TAB & DllStructGetData($tBuffer, "Text") & @CRLF & _ "-->TextMax:" & @TAB & DllStructGetData($tInfo, "TextMax") & @CRLF & _ "-->Image:" & @TAB & DllStructGetData($tInfo, "Image") & @CRLF & _ "-->Param:" & @TAB & DllStructGetData($tInfo, "Param") & @CRLF & _ "-->Indent:" & @TAB & DllStructGetData($tInfo, "Indent") & @CRLF & _ "-->GroupID:" & @TAB & DllStructGetData($tInfo, "GroupID") & @CRLF & _ "-->Columns:" & @TAB & DllStructGetData($tInfo, "Columns") & @CRLF & _ "-->pColumns:" & @TAB & DllStructGetData($tInfo, "pColumns")) ; Si Text n'est pas vide, retourne True pour définir l'étiquette de l'élément avec le texte édité, retourne False pour annuler ; If Text est vide, la valeur retournée est ignorée If StringLen(DllStructGetData($tBuffer, "Text")) Then Return True Case $NM_CLICK ; Envoyé par le contrôle ListView quand l'utilisateur clique sur un élément avec le bouton gauche de la souris $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam) _DebugPrint("$NM_CLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode & @CRLF & _ "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _ "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _ "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _ "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _ "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _ "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _ "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _ "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _ "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags")) ; Aucune valeur retournée Case $NM_DBLCLK ; Envoyé par le contrôle ListView quand l'utilisateur double-clique sur un élément avec le bouton gauche de la souris $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam) _DebugPrint("$NM_DBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode & @CRLF & _ "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _ "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _ "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _ "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _ "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _ "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _ "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _ "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _ "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags")) ; Aucune valeur retournée Case $NM_KILLFOCUS ; Le contrôle a perdu le focus d'entrée _DebugPrint("$NM_KILLFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode) ; Aucune valeur retournée Case $NM_RCLICK ; Envoyé par le contrôle ListView quand l'utilisateur clique sur un élément avec le bouton droit de la souris $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam) _DebugPrint("$NM_RCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode & @CRLF & _ "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _ "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _ "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _ "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _ "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _ "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _ "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _ "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _ "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags")) ; Return 1 ; Ne permet pas le traitement par défaut Return 0 ; Permet le traitement par défaut Case $NM_RDBLCLK ; Envoyé par le contrôle ListView quand l'utilisateur double-clique sur un élément avec le bouton droit de la souris $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam) _DebugPrint("$NM_RDBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode & @CRLF & _ "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _ "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _ "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _ "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _ "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _ "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _ "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _ "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _ "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags")) ; Aucune valeur retournée Case $NM_RETURN ; Le contrôle a le focus d'entrée et l'utilisateur a pressé la touche ENTER _DebugPrint("$NM_RETURN" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode) ; Aucune valeur retournée Case $NM_SETFOCUS ; Le contrôle a reçu le focus d'entrée _DebugPrint("$NM_SETFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode) ; Aucune valeur retournée EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber) ConsoleWrite( _ "!===========================================================" & @CRLF & _ "+======================================================" & @CRLF & _ "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _ "+======================================================" & @CRLF) EndFunc ;==>_DebugPrint ; Ecrit une ligne dans le contrôle mémo Func MemoWrite($sMessage) GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1) EndFunc ;==>MemoWrite