je travaille encore sur ma treeview et j'ai un soucis avec les checkbox qu'elle contient. J'ai besoin de contrôler le clic sur les checkbox mais je ne sais pas comment faire.
Voici un bout de script d'exemple... comment faudrait-il s'y prendre pour mettre ou enlever le gras sur l'item que l'on coche ou décoche ? (pour un comportement similaire au double-clic de mon script ci-dessous)
Code : Tout sélectionner
#include <GuiConstantsEx.au3>
#include <GuiTreeView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
Main()
Exit 0
Func gestionGras($hTreeView)
Local $item = _GUICtrlTreeView_GetSelection($hTreeView)
_GUICtrlTreeView_SetBold($hTreeView,$item,Not _GUICtrlTreeView_GetBold($hTreeView, $item))
EndFunc
Func gestionCheck($hTreeView)
Local $item = _GUICtrlTreeView_GetSelection($hTreeView)
_GUICtrlTreeView_SetChecked($hTreeView,$item,Not _GUICtrlTreeView_GetChecked($hTreeView, $item))
EndFunc
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndTreeview
$hWndTreeview = $hTreeView
If Not IsHWnd($hTreeView) Then $hWndTreeview = GUICtrlGetHandle($hTreeView)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndTreeview ;- geston de le Treegestion2
Switch $iCode
Case $NM_CLICK ; The user has clicked the left mouse button within the control
Return 0 ; zero to allow the default processing
Case $TVN_SELCHANGING, $TVN_SELCHANGINGW
Return 0 ; zero to allow the default processing
Case $NM_DBLCLK
gestionGras($hTreeView)
gestionCheck($hTreeView)
Return 0 ; zero to allow the default processing
Case Else
_DebugPrint("code: " & $iCode)
EndSwitch
Case Else
Return 0
EndSwitch
EndFunc
Func _DebugPrint($s_text, $line = @ScriptLineNumber)
ConsoleWrite( _
"!===========================================================" & @MIN & @SEC & @MSEC & @LF & _
"+======================================================" & @LF & _
"-->Line(" & StringFormat("%04d", $line) & "):" & @TAB & $s_text & @LF & _
"+======================================================" & @LF)
EndFunc ;==>_DebugPrint
Func Main()
Local $iStyle = BitOR($TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)
Local $hItem[6], $hImage
GUICreate("TreeView Get Edit Control", 400, 300)
Global $hTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
GUISetState()
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
$hImage = _GUIImageList_Create(16, 16, 5, 3)
_GUIImageList_AddIcon($hImage, "shell32.dll", 110)
_GUIImageList_AddIcon($hImage, "shell32.dll", 131)
_GUIImageList_AddIcon($hImage, "shell32.dll", 165)
_GUIImageList_AddIcon($hImage, "shell32.dll", 168)
_GUIImageList_AddIcon($hImage, "shell32.dll", 137)
_GUIImageList_AddIcon($hImage, "shell32.dll", 146)
_GUICtrlTreeView_SetNormalImageList($hTreeView, $hImage)
For $x = 0 To _GUIImageList_GetImageCount($hImage) - 1
$hItem[$x] = _GUICtrlTreeView_Add($hTreeView, 0, StringFormat("[%02d] New Item", $x + 1), $x, $x)
Next
; Edit item 0 label
_GUICtrlTreeView_EditText($hTreeView, $hItem[0])
Sleep(1000)
_GUICtrlTreeView_EndEdit($hTreeView)
; Loop until user exits
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc

