Page 1 sur 1
[R] Fonction lors d'un clic sur une ligne d'une listview
Posté : lun. 01 sept. 2014 19:04
par Itachi31
Bonjour,
je souhaiterais avoir des informations concernant la sélection d'une ou plusieurs lignes dans une listview.
Quand je clic sur une ligne, je voudrais qu'une fonction se lance et m'affiche le nombre de ligne sélectionné mais je n'ai rien trouvé dans le fichier d'aide.
Pourriez-vous m'aider ?
Merci !
Re: Fonction lors d'un clic sur une ligne d'une listview
Posté : lun. 01 sept. 2014 19:08
par jguinch
Merci de modifier le titre du sujet afin qu'il respecte les
règles de présentation d'un message.
Re: [..] Fonction lors d'un clic sur une ligne d'une listvie
Posté : lun. 01 sept. 2014 21:43
par Hugues
Salut,
Il faut que tu utilises
Tu trouveras facilement sur Internet, dans ce forum des exemples concrets.
Exemple de Mikell (le résultat est dans la Console):
► Afficher le texte
Code : Tout sélectionner
#include <WindowsConstants.au3>
#include <StructureConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
GUICreate("", 600, 500)
$List2 = GUICtrlCreateListView("test", 10, 10, 200, 400)
GUICtrlCreateListViewItem("ligne1", $List2)
GUICtrlCreateListViewItem("ligne2", $List2)
$List3 = GUICtrlCreateListView("test", 220, 10, 200, 400)
GUICtrlCreateListViewItem("ligne1", $List3)
GUICtrlCreateListViewItem("ligne2", $List3)
GUISetState()
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
While GUIGetMsg() <> $GUI_EVENT_CLOSE
Sleep(10)
WEnd
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $hWndListViewTwo, $tInfo
$hWndListViewTwo = GuiCtrlGetHandle($List2)
$hWndListView = GUICtrlGetHandle($List3)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListViewTwo, $hWndListView
Switch $iCode
Case $NM_DBLCLK ; Si simple clic -> $NM_CLICK
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
$index = DllStructGetData($tInfo, "Index")
$iIndex = _GUICtrlListView_GetSelectedIndices($hWndFrom) ; ou ($iIDFrom)
If ($iIndex) <> "" Then
If $iIDFrom = $List2 Then ConsoleWrite("DDBLCLK $List2 : Index=" & $iIndex & @CRLF)
If $iIDFrom = $List3 Then ConsoleWrite("DDBLCLK $List3 : Index=" & $iIndex & @CRLF)
Endif
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Re: [..] Fonction lors d'un clic sur une ligne d'une listvie
Posté : mar. 02 sept. 2014 11:40
par Itachi31
Merci, c'est bien ce que je cherchais!
Re: [R] Fonction lors d'un clic sur une ligne d'une listview
Posté : mar. 02 sept. 2014 14:20
par TommyDDR
Vous avez aussi un bel UDF :
_GUIXView.au3