Obtient le handle du contr�le d'�dition qui est utilis� pour modifier le texte d'un �l�ment
#include <GuiListView.au3>
_GUICtrlListView_GetEditControl ( $hWnd )
$hWnd | ID/handle du contr�le |
Succ�s: | Retourne le handle du contr�le d'�dition. |
�chec: | Retourne 0. |
Lorsque l'�dition d'�tiquette commence, un contr�le d'�dition est cr��, positionn�, et initialis�.
Avant de l'afficher, le contr�le envoie � sa fen�tre parent un message de notification $LVN_BEGINLABELEDIT.
Si vous voulez personnaliser l'�dition d'�tiquette, il faut impl�menter un gestionnaire pour $LVN_BEGINLABELEDITA, $LVN_BEGINLABELEDITAW et qu'il envoie un message $LVM_GETEDITCONTROL au contr�le.
Si une �tiquette est en cours de modification, la valeur de retour sera le handle du contr�le d'�dition.
Utilisez ce handle pour personnaliser le contr�le d'�dition en envoyant les messages habituels EM_XXX.
Lorsque l'utilisateur termine ou annule l'�dition, le contr�le d'�dition est d�truit et le handle n'est plus valide.
Vous pouvez subclass le contr�le d'�dition, mais vous ne devriez pas le d�truire.
Pour annuler l'�dition, envoyez au contr�le un message $WM_CANCELMODE.
L'�l�ment du contr�le en cours d'�dition est l'�l�ment qui a actuellement le focus.
Pour rechercher un �l�ment � partir de son �tat, utilisez un message $LVM_GETNEXTITEM.
_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 Get Edit Control", 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) _GUICtrlListView_SetExtendedListViewStyle($g_hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER)) GUISetState(@SW_SHOW) ; Charge les images $hImage = _GUIImageList_Create() _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($g_hListView), 0xFF0000, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($g_hListView), 0x00FF00, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($g_hListView), 0x0000FF, 16, 16)) _GUICtrlListView_SetImageList($g_hListView, $hImage, 1) ; Ajoute des colonnes _GUICtrlListView_AddColumn($g_hListView, "Column 1", 100) _GUICtrlListView_AddColumn($g_hListView, "Column 2", 100) _GUICtrlListView_AddColumn($g_hListView, "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) ; R�pond au message WM_NOTIFY. GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") _GUICtrlListView_EditLabel($g_hListView, 0) MemoWrite("Edit Handle: 0x" & Hex(_GUICtrlListView_GetEditControl($g_hListView)) & _ " IsPtr = " & IsPtr(_GUICtrlListView_GetEditControl($g_hListView)) & " IsHWnd = " & IsHWnd(_GUICtrlListView_GetEditControl($g_hListView))) ; 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, $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 d'un �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 ; Autorise l'utilisateur � �diter l'�tiquette ; ; Return True ; Emp�che l'utilisateur d'�diter 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_ENDLABELEDITA, $LVN_ENDLABELEDITW ; La fin de l'�dition de l'�tiquette d'un �l�ment $tInfo = DllStructCreate($tagNMLVDISPINFO, $lParam) If (DllStructGetData($tInfo, "Text") <> 0) Then 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")) Return True ; If Text is empty the return value is ignored EndIf Case $NM_CLICK ; Envoy� par un contr�le ListView quand l'utiisateur 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 un contr�le ListView quand l'utiisateur 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 un contr�le ListView quand l'utiisateur 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 un 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