Page 1 sur 1
[R] Problème avec $WM_NOTIFY
Posté : lun. 16 sept. 2013 13:51
par Hugues
Bonjour à tous,
Je suis confronté à un problème avec "GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")".
En effet, j'ai 2 GUI et dans chaque GUI une ListView.
Le soucis est que ça ne reconnait qu'une seule ListView... comment faire pour detecter le double clic de telle ou telle ListView pour faire un Case dans la fonction (Si cela est faisable...):
► Afficher le texte
Code : Tout sélectionner
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
Local $tBuffer
;SI CLIC ListView1 ALORS
$hWndListView = "$ListView1"
;SINON
$hWndListView = "$ListView3"
;;;;If Not IsHWnd($ListView1) Then $hWndListView = GUICtrlGetHandle($ListView1)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListView = "$ListView1"
Switch $iCode
Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
If _GUICtrlListView_GetNextItem($ListView1) = -1 Then
Return
Else
_MaFonction1()
EndIf
EndSwitch
Case $hWndListView = "$ListView3"
Switch $iCode
Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
If _GUICtrlListView_GetNextItem($ListView3) = -1 Then
Return
Else
_MaFonction2()
EndIf
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Merci par avance.
Re: [..] Problème avec $WM_NOTIFY
Posté : lun. 16 sept. 2013 15:20
par jguinch
Pourquoi est-ce que tu mets tes doubles quotes ?
Case $hWndListView = "$ListView1" ???
Case $hWndListView = $ListView1
Re: [..] Problème avec $WM_NOTIFY
Posté : lun. 16 sept. 2013 15:31
par mikell
@jguinch
Le gag classique... c'est un switch pas un select
► Afficher le texte
Code : Tout sélectionner
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $tInfo
Local $hWndListView1 = $ListView1
If Not IsHWnd($hWndListView1) Then $hWndListView1 = GUICtrlGetHandle($ListView1)
Local $hWndListView3 = $ListView3
If Not IsHWnd($hWndListView3) Then $hWndListView3 = GUICtrlGetHandle($ListView3)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListView1
Switch $iCode
Case $NM_DBLCLK
....
EndSwitch
Case $hWndListView3
Switch $iCode
Case $NM_DBLCLK
....
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Re: [..] Problème avec $WM_NOTIFY
Posté : lun. 16 sept. 2013 15:36
par jguinch
Ah le c.., j'ai pas fait gaffe ! C'est les doubles quotes qui m'ont sauté aux yeux
Re: [..] Problème avec $WM_NOTIFY
Posté : lun. 16 sept. 2013 16:22
par mikell
Je peux rien dire, je me suis fait piéger pareil (et j'ai eu la même réaction)
http://www.autoitscript.fr/forum/viewto ... 002#p81002
En fait il y a 3 erreurs sur cette ligne
- les doubles quotes
- la syntaxe du select pour un switch
- le $ListView1 qui est peut-être un ID et pas un handle (pas vérifié avant)
Re: [..] Problème avec $WM_NOTIFY
Posté : lun. 16 sept. 2013 16:27
par Hugues
Bon bin sujet résolu...

Merci
