[R] Action sur listview - récupération d'item
Posté : lun. 18 févr. 2019 22:39
Bonjour.
Je cherche à récupérer - consolewrite / msgbox / variable - un item et son sous-item lors d'un clic sur le dit item d'une listview...
Le problème : Je sais le faire, quand il n'y a qu'une seule listview, comme ceci : https://www.autoitscript.com/forum/topi ... ent=586083
Avec
Le véritable problème : je souhaite récupérer donc l'item et sous item de n'importe quel listview...
Je pensais donc créer plusieurs WM_NOTIFY, un pour chaque listview.
Je pense m'être bercé d'illusion
J'ai volontairement réduit le script, afin de se baser sur le "phénomène"
Je pense avoir compris ceci : dans ce script, il ne peut qu'avoir un seul $WM_NOTIFY. Donc le dernier est uniquement pris en compte...
Pouvez-vous m'aiguiller ? Merci
@++
Je cherche à récupérer - consolewrite / msgbox / variable - un item et son sous-item lors d'un clic sur le dit item d'une listview...
Le problème : Je sais le faire, quand il n'y a qu'une seule listview, comme ceci : https://www.autoitscript.com/forum/topi ... ent=586083
Avec
WM_NOTIFY($hWnd, $Msg, $wParam, $lParam)
Le véritable problème : je souhaite récupérer donc l'item et sous item de n'importe quel listview...
Je pensais donc créer plusieurs WM_NOTIFY, un pour chaque listview.
Je pense m'être bercé d'illusion
J'ai volontairement réduit le script, afin de se baser sur le "phénomène"
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <GuiListView.au3>
Global $Form1 = GUICreate("Form1", 1215, 765, (@DesktopWidth - 1215) / 2, (@DesktopHeight - 765) / 2 - 30)
GUISetFont(9, 500, 0, 'comic sans ms')
$lv_32x = GUICtrlCreateListView("Choix #1|Choix #2", 0, 0, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)
$lv_gg = GUICtrlCreateListView("Choix #1|Choix #2", 305, 0, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)
$lv_gb = GUICtrlCreateListView("Choix #1|Choix #2", 610, 0, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)
$lv_gba = GUICtrlCreateListView("Choix #1|Choix #2", 915, 0, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)
$lv_gbc = GUICtrlCreateListView("Choix #1|Choix #2", 0, 255, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)
$lv_ms = GUICtrlCreateListView("Choix #1|Choix #2", 305, 255, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)
$lv_mgd = GUICtrlCreateListView("Choix #1|Choix #2", 610, 255, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)
$lv_nes = GUICtrlCreateListView("Choix #1|Choix #2", 915, 255, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)
$lv_psx1 = GUICtrlCreateListView("Choix #1|Choix #2", 0, 510, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)
$lv_psx2 = GUICtrlCreateListView("Choix #1|Choix #2", 305, 510, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)
$lv_snes = GUICtrlCreateListView("Choix #1|Choix #2", 610, 510, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)
GUICtrlCreateLabel('input #1', 925, 550, 110, 20)
GUICtrlSetFont(-1, 10)
$cs_em = GUICtrlCreateInput('', 1050, 550, 140, 20)
GUICtrlSetFont(-1, 10)
GUICtrlCreateLabel('input #2', 925, 590, 110, 20)
GUICtrlSetFont(-1, 10)
$jx_sl = GUICtrlCreateInput('', 1050, 590, 140, 20)
GUICtrlSetFont(-1, 10)
$Go = GUICtrlCreateButton("Go !", 925, 700, 280, 40)
GUICtrlSetFont(-1, 12)
_lslv()
GUICtrlSendMsg($lv_32x, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_gg, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_gb, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_gba, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_gbc, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_ms, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_mgd, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_nes, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_psx1, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_psx2, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_snes, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY_32X")
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY_GG")
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func _lslv()
For $a = 1 To 10
GUICtrlCreateListViewItem($a&"|"&$a+1, $lv_32x)
Next
For $a = 2 To 11
GUICtrlCreateListViewItem($a&"|"&$a+1, $lv_gg)
Next
For $a = 3 To 12
GUICtrlCreateListViewItem($a&"|"&$a+1, $lv_gb)
Next
For $a = 4 To 13
GUICtrlCreateListViewItem($a&"|"&$a+1, $lv_gba)
Next
For $a = 5 To 14
GUICtrlCreateListViewItem($a&"|"&$a+1, $lv_gbc)
Next
For $a = 6 To 15
GUICtrlCreateListViewItem($a&"|"&$a+1, $lv_ms)
Next
For $a = 7 To 16
GUICtrlCreateListViewItem($a&"|"&$a+1, $lv_mgd)
Next
For $a = 8 To 17
GUICtrlCreateListViewItem($a&"|"&$a+1, $lv_nes)
Next
For $a = 9 To 18
GUICtrlCreateListViewItem($a&"|"&$a+1, $lv_psx1)
Next
For $a = 10 To 19
GUICtrlCreateListViewItem($a&"|"&$a+1, $lv_psx1)
Next
For $a = 11 To 20
GUICtrlCreateListViewItem($a&"|"&$a+1, $lv_psx2)
Next
For $a = 12 To 21
GUICtrlCreateListViewItem($a&"|"&$a+1, $lv_snes)
Next
EndFunc ;==>_jeux
; EMULATION :
; -----------
; 32X : KegaFusion
; Game Gear : BizHawk
; GameBoy : BizHawk
; GameBoy Advance : BizHawk
; GameBoy Color : BizHawk
; Master System : BizHawk
; Megadrive : BizHawk
; Nintendo Nes : BizHawk
; Playstation :
; Playstation 2 :
; Super Nintendo : BizHawk
Func WM_NOTIFY_32X($hWnd, $Msg, $wParam, $lParam)
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView
$hWndListView = $lv_32x
If Not IsHWnd($hWndListView) Then $hWndListView = GUICtrlGetHandle($lv_32x)
$tNMHDR = DllStructCreate($tagNMHDR, $lParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListView
Switch $iCode
Case $NM_CLICK
$indice = _GUICtrlListView_GetSelectedIndices($lv_32x)
$console = _GUICtrlListView_GetItem($lv_32x, Int($indice), 0)[3]
$jeu = _GUICtrlListView_GetItem($lv_32x, Int($indice), 1)[3]
GUICtrlSetData($cs_em, $console)
GUICtrlSetData($jx_sl, $jeu)
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Func WM_NOTIFY_GG($hWnd, $Msg, $wParam, $lParam)
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView
$hWndListView = $lv_gg
If Not IsHWnd($hWndListView) Then $hWndListView = GUICtrlGetHandle($lv_gg)
$tNMHDR = DllStructCreate($tagNMHDR, $lParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListView
Switch $iCode
Case $NM_CLICK
$indice = _GUICtrlListView_GetSelectedIndices($lv_gg)
$console = _GUICtrlListView_GetItem($lv_gg, Int($indice), 0)[3]
$jeu = _GUICtrlListView_GetItem($lv_gg, Int($indice), 1)[3]
GUICtrlSetData($cs_em, $console)
GUICtrlSetData($jx_sl, $jeu)
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
#include <WindowsConstants.au3>
#include <File.au3>
#include <GuiListView.au3>
Global $Form1 = GUICreate("Form1", 1215, 765, (@DesktopWidth - 1215) / 2, (@DesktopHeight - 765) / 2 - 30)
GUISetFont(9, 500, 0, 'comic sans ms')
$lv_32x = GUICtrlCreateListView("Choix #1|Choix #2", 0, 0, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)
$lv_gg = GUICtrlCreateListView("Choix #1|Choix #2", 305, 0, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)
$lv_gb = GUICtrlCreateListView("Choix #1|Choix #2", 610, 0, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)
$lv_gba = GUICtrlCreateListView("Choix #1|Choix #2", 915, 0, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)
$lv_gbc = GUICtrlCreateListView("Choix #1|Choix #2", 0, 255, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)
$lv_ms = GUICtrlCreateListView("Choix #1|Choix #2", 305, 255, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)
$lv_mgd = GUICtrlCreateListView("Choix #1|Choix #2", 610, 255, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)
$lv_nes = GUICtrlCreateListView("Choix #1|Choix #2", 915, 255, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)
$lv_psx1 = GUICtrlCreateListView("Choix #1|Choix #2", 0, 510, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)
$lv_psx2 = GUICtrlCreateListView("Choix #1|Choix #2", 305, 510, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)
$lv_snes = GUICtrlCreateListView("Choix #1|Choix #2", 610, 510, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)
GUICtrlCreateLabel('input #1', 925, 550, 110, 20)
GUICtrlSetFont(-1, 10)
$cs_em = GUICtrlCreateInput('', 1050, 550, 140, 20)
GUICtrlSetFont(-1, 10)
GUICtrlCreateLabel('input #2', 925, 590, 110, 20)
GUICtrlSetFont(-1, 10)
$jx_sl = GUICtrlCreateInput('', 1050, 590, 140, 20)
GUICtrlSetFont(-1, 10)
$Go = GUICtrlCreateButton("Go !", 925, 700, 280, 40)
GUICtrlSetFont(-1, 12)
_lslv()
GUICtrlSendMsg($lv_32x, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_gg, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_gb, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_gba, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_gbc, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_ms, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_mgd, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_nes, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_psx1, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_psx2, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_snes, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY_32X")
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY_GG")
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func _lslv()
For $a = 1 To 10
GUICtrlCreateListViewItem($a&"|"&$a+1, $lv_32x)
Next
For $a = 2 To 11
GUICtrlCreateListViewItem($a&"|"&$a+1, $lv_gg)
Next
For $a = 3 To 12
GUICtrlCreateListViewItem($a&"|"&$a+1, $lv_gb)
Next
For $a = 4 To 13
GUICtrlCreateListViewItem($a&"|"&$a+1, $lv_gba)
Next
For $a = 5 To 14
GUICtrlCreateListViewItem($a&"|"&$a+1, $lv_gbc)
Next
For $a = 6 To 15
GUICtrlCreateListViewItem($a&"|"&$a+1, $lv_ms)
Next
For $a = 7 To 16
GUICtrlCreateListViewItem($a&"|"&$a+1, $lv_mgd)
Next
For $a = 8 To 17
GUICtrlCreateListViewItem($a&"|"&$a+1, $lv_nes)
Next
For $a = 9 To 18
GUICtrlCreateListViewItem($a&"|"&$a+1, $lv_psx1)
Next
For $a = 10 To 19
GUICtrlCreateListViewItem($a&"|"&$a+1, $lv_psx1)
Next
For $a = 11 To 20
GUICtrlCreateListViewItem($a&"|"&$a+1, $lv_psx2)
Next
For $a = 12 To 21
GUICtrlCreateListViewItem($a&"|"&$a+1, $lv_snes)
Next
EndFunc ;==>_jeux
; EMULATION :
; -----------
; 32X : KegaFusion
; Game Gear : BizHawk
; GameBoy : BizHawk
; GameBoy Advance : BizHawk
; GameBoy Color : BizHawk
; Master System : BizHawk
; Megadrive : BizHawk
; Nintendo Nes : BizHawk
; Playstation :
; Playstation 2 :
; Super Nintendo : BizHawk
Func WM_NOTIFY_32X($hWnd, $Msg, $wParam, $lParam)
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView
$hWndListView = $lv_32x
If Not IsHWnd($hWndListView) Then $hWndListView = GUICtrlGetHandle($lv_32x)
$tNMHDR = DllStructCreate($tagNMHDR, $lParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListView
Switch $iCode
Case $NM_CLICK
$indice = _GUICtrlListView_GetSelectedIndices($lv_32x)
$console = _GUICtrlListView_GetItem($lv_32x, Int($indice), 0)[3]
$jeu = _GUICtrlListView_GetItem($lv_32x, Int($indice), 1)[3]
GUICtrlSetData($cs_em, $console)
GUICtrlSetData($jx_sl, $jeu)
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Func WM_NOTIFY_GG($hWnd, $Msg, $wParam, $lParam)
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView
$hWndListView = $lv_gg
If Not IsHWnd($hWndListView) Then $hWndListView = GUICtrlGetHandle($lv_gg)
$tNMHDR = DllStructCreate($tagNMHDR, $lParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListView
Switch $iCode
Case $NM_CLICK
$indice = _GUICtrlListView_GetSelectedIndices($lv_gg)
$console = _GUICtrlListView_GetItem($lv_gg, Int($indice), 0)[3]
$jeu = _GUICtrlListView_GetItem($lv_gg, Int($indice), 1)[3]
GUICtrlSetData($cs_em, $console)
GUICtrlSetData($jx_sl, $jeu)
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Je pense avoir compris ceci : dans ce script, il ne peut qu'avoir un seul $WM_NOTIFY. Donc le dernier est uniquement pris en compte...
Pouvez-vous m'aiguiller ? Merci
@++