J'aimerai de l'aide sur un script
► Afficher le texte
Code : Tout sélectionner
#include <StructureConstants.au3>
#include <GuiImageList.au3>
#include <TreeViewConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiTreeView.au3>
#include <File.au3>
#include <ListviewConstants.au3>
$sPath = 'C:'
$sPathh = 'D:'
$hGui = GUICreate('', 400, 400)
$hTreeview = GUICtrlCreateTreeView(10, 10, 380, 360, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $LVS_NOCOLUMNHEADER, $LVS_EX_CHECKBOXES+ $WS_EX_CLIENTEDGE))
$hWndTreeview = GUICtrlGetHandle($hTreeview)
$hOk = GUICtrlCreateButton('Ok', 240, 375, 60, 22)
$hCancel = GUICtrlCreateButton('Cancel', 320, 375, 60, 22)
$hImage = _GUIImageList_Create(16, 16, 5, 3)
_GUIImageList_AddIcon($hImage, 'shell32.dll', 4)
_GUIImageList_AddIcon($hImage, 'shell32.dll', 1)
_GUICtrlTreeView_SetNormalImageList($hTreeview, $hImage)
GUISetState()
GUICtrlSetStyle($hTreeview, Default, $WS_EX_COMPOSITED + $WS_EX_CLIENTEDGE)
;~ ######################################################################################################################## integration des repertoires
$hRoot = _GUICtrlTreeView_Add($hTreeview, $hTreeview, $sPath, 0, 0)
_GUICtrlTreeView_SetState($hTreeview, $hRoot, $TVIS_EXPANDED)
$hRoot1 = _GUICtrlTreeView_Add($hTreeview, $hTreeview, $sPathh, 0, 0)
_GUICtrlTreeView_SetState($hTreeview, $hRoot, $TVIS_EXPANDED)
;~ ######################################################################################################################## arborescence des repertoires
_GUICtrlTreeView_BeginUpdate($hTreeview)
GUISetCursor(15, 1, $hGui)
_GUICtrlTreeView_FileExplorerRecursive($hTreeview, $hRoot, $sPath, 2)
GUISetCursor(2, 1, $hGui)
_GUICtrlTreeView_EndUpdate($hTreeview)
_GUICtrlTreeView_BeginUpdate($hTreeview)
GUISetCursor(15, 1, $hGui)
_GUICtrlTreeView_FileExplorerRecursive($hTreeview, $hRoot, $sPathh, 2)
GUISetCursor(2, 1, $hGui)
_GUICtrlTreeView_EndUpdate($hTreeview)
GUICtrlSetState(-1, $GUI_CHECKED)
;~ ######################################################################################################################## choix boutons
GUIRegisterMsg($WM_NOTIFY, '_WM_NOTIFY')
While True
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE, $hCancel
Exit
Case $hOk
_GUIImageList_Destroy($hImage)
$iSelect = _GUICtrlTreeView_GetSelection($hTreeview)
$sTree = StringReplace(_GUICtrlTreeView_GetTree($hTreeview, $iSelect), '|', '\')
MsgBox(0, 'Selected Path/File', $sTree)
EndSwitch
WEnd
;~ ######################################################################################################################## Fonction
Func _WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
GUIRegisterMsg($WM_NOTIFY, '')
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, 'hWndFrom'))
$iCode = DllStructGetData($tNMHDR, 'Code')
If $hWndFrom = $hWndTreeview And $iCode = $NM_CLICK Then
ToolTip('Please wait...', Default, Default, 'Read Directory', 1)
_GUICtrlTreeView_FileExplorer($hGui, $hTreeview)
ToolTip('')
EndIf
GUIRegisterMsg($WM_NOTIFY, '_WM_NOTIFY')
Return $GUI_RUNDEFMSG
EndFunc ;==>_WM_NOTIFY
;~ ######################################################################################################################## Fonction
Func _GUICtrlTreeView_FileExplorer($hGui, $hTreeview)
Local $aTVPos, $aPos, $hItem, $hChild, $sTree
$aTVPos = ControlGetPos($hGui, '', $hTreeview)
$aPos = GUIGetCursorInfo($hGui)
$check= GUICtrlSetState(-1, $GUI_CHECKED)
$hItem = _GUICtrlTreeView_HitTestItem($hTreeview, $aPos[0], $aPos[1] - $aTVPos[1])
If _GUICtrlTreeView_GetExpanded($hTreeview, $hItem) Then Return
$hChild = _GUICtrlTreeView_GetFirstChild($hTreeview, $hItem)
_GUICtrlTreeView_BeginUpdate($hTreeview)
If $hChild <> 0 Then
$sTree = StringReplace(_GUICtrlTreeView_GetTree($hTreeview, $hChild), '|', '\')
_GUICtrlTreeView_DeleteChildren($hTreeview, $hChild)
_GUICtrlTreeView_FileExplorerRecursive($hTreeview, $hChild, $sTree, 1)
EndIf
Do
$hChild = _GUICtrlTreeView_GetNextChild($hTreeview, $hChild)
If $hChild <> 0 Then
$sTree = StringReplace(_GUICtrlTreeView_GetTree($hTreeview, $hChild), '|', '\')
_GUICtrlTreeView_DeleteChildren($hTreeview, $hChild)
$iTimer = TimerInit()
_GUICtrlTreeView_FileExplorerRecursive($hTreeview, $hChild, $sTree, 1)
EndIf
Until $hChild = 0
_GUICtrlTreeView_EndUpdate($hTreeview)
EndFunc ;==>_GUICtrlTreeView_FileExplorer
;~ ######################################################################################################################## Fonction
Func _GUICtrlTreeView_FileExplorerRecursive($hTreeview, $hItem, $sPath, $iRec)
Local $aDirList, $aFileList, $tmp, $hIcon
$iRec -= 1
$aDirList = _FileListToArray($sPath, '*', 2)
If IsArray($aDirList) Then
For $i = 1 To $aDirList[0]
If Not StringInStr(FileGetAttrib($sPath & '\' & $aDirList[$i]), 's') Then
$tmp = _GUICtrlTreeView_AddChild($hTreeview, $hItem, $aDirList[$i], 0, 0)
If $iRec > 0 Then _GUICtrlTreeView_FileExplorerRecursive($hTreeview, $tmp, $sPath & '\' & $aDirList[$i], $iRec)
EndIf
Next
EndIf
$aFileList = _FileListToArray($sPath, '*', 1)
If IsArray($aFileList) Then
For $i = 1 To $aFileList[0]
If Not StringInStr(FileGetAttrib($sPath & '\' & $aFileList[$i]), 's') Then
$hIcon = _GUIImageList_AddIcon($hImage, $sPath & '\' & $aFileList[$i], 0)
If $hIcon = 0 Then
$hIcon = 1
Else
_GUICtrlTreeView_SetNormalImageList($hTreeview, $hImage)
EndIf
$tmp = _GUICtrlTreeView_AddChild($hTreeview, $hItem, $aFileList[$i], $hIcon, $hIcon)
EndIf
Next
EndIf
EndFunc ;==>_GUICtrlTreeView_FileExplorerRecursivecela est-il possible
Merci d'avance
Toma


