Jump to content

multi icon in Treeview


Recommended Posts

i insert also winapix.au3 in include but give me this error

C:UsersstefanoDocumentsprogrammazioneUDF-AGGIUNTIVETVExplorerTVExplorer.au3(833,66) : WARNING: $SEM_FAILCRITICALERRORS: possibly used before declaration.
Local $Mode = _WinAPI_SetErrorMode(BitOR($SEM_FAILCRITICALERRORS,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersstefanoDocumentsprogrammazioneUDF-AGGIUNTIVETVExplorerTVExplorer.au3(833,91) : WARNING: $SEM_NOOPENFILEERRORBOX: possibly used before declaration.
Local $Mode = _WinAPI_SetErrorMode(BitOR($SEM_FAILCRITICALERRORS, $SEM_NOOPENFILEERRORBOX)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersstefanoDocumentsprogrammazioneUDF-AGGIUNTIVETVExplorerTVExplorer.au3(945,39) : WARNING: $SHGFI_SMALLICON: possibly used before declaration.
Local $Flags = BitOR($SHGFI_SMALLICON,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersstefanoDocumentsprogrammazioneUDF-AGGIUNTIVETVExplorerTVExplorer.au3(945,60) : WARNING: $SHGFI_SYSICONINDEX: possibly used before declaration.
Local $Flags = BitOR($SHGFI_SMALLICON, $SHGFI_SYSICONINDEX)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersstefanoDocumentsprogrammazioneUDF-AGGIUNTIVETVExplorerTVExplorer.au3(949,33) : WARNING: $SHGFI_OPENICON: possibly used before declaration.
  $Flags = BitOR($SHGFI_OPENICON,
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersstefanoDocumentsprogrammazioneUDF-AGGIUNTIVETVExplorerTVExplorer.au3(994,61) : WARNING: $SHGFI_ICON: possibly used before declaration.
   $hIL = _WinAPI_ShellGetFileInfo($sPath, BitOR($SHGFI_ICON,
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersstefanoDocumentsprogrammazioneUDF-AGGIUNTIVETVExplorerTVExplorer.au3(994,82) : WARNING: $SHGFI_OVERLAYINDEX: possibly used before declaration.
   $hIL = _WinAPI_ShellGetFileInfo($sPath, BitOR($SHGFI_ICON, $SHGFI_OVERLAYINDEX,
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersstefanoDocumentsprogrammazioneUDF-AGGIUNTIVETVExplorerTVExplorer.au3(994,108) : WARNING: $SHGFI_USEFILEATTRIBUTES: possibly used before declaration.
   $hIL = _WinAPI_ShellGetFileInfo($sPath, BitOR($SHGFI_ICON, $SHGFI_OVERLAYINDEX, $SHGFI_USEFILEATTRIBUTES,
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersstefanoDocumentsprogrammazioneUDF-AGGIUNTIVETVExplorerTVExplorer.au3(1082,40) : WARNING: $SSF_SHOWALLOBJECTS: possibly used before declaration.
Local $Param[3] = [$SSF_SHOWALLOBJECTS,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersstefanoDocumentsprogrammazioneUDF-AGGIUNTIVETVExplorerTVExplorer.au3(1082,64) : WARNING: $SSF_SHOWEXTENSIONS: possibly used before declaration.
Local $Param[3] = [$SSF_SHOWALLOBJECTS, 0, $SSF_SHOWEXTENSIONS]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersstefanoDocumentsprogrammazioneUDF-AGGIUNTIVETVExplorerTVExplorer.au3(1362,28) : WARNING: $SIID_DOCNOASSOC: possibly used before declaration.
  $ID[0] = $SIID_DOCNOASSOC
  ~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersstefanoDocumentsprogrammazioneUDF-AGGIUNTIVETVExplorerTVExplorer.au3(1363,24) : WARNING: $SIID_FOLDER: possibly used before declaration.
  $ID[1] = $SIID_FOLDER
  ~~~~~~~~~~~~~~~~~~~~~^
C:UsersstefanoDocumentsprogrammazioneUDF-AGGIUNTIVETVExplorerTVExplorer.au3(1364,28) : WARNING: $SIID_FOLDEROPEN: possibly used before declaration.
  $ID[2] = $SIID_FOLDEROPEN
  ~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersstefanoDocumentsprogrammazioneUDF-AGGIUNTIVETVExplorerTVExplorer.au3(1366,69) : WARNING: $SHGSI_ICON: possibly used before declaration.
   $tIcon = _WinAPI_ShellGetStockIconInfo($ID[$i], BitOR($SHGSI_ICON,
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersstefanoDocumentsprogrammazioneUDF-AGGIUNTIVETVExplorerTVExplorer.au3(1366,87) : WARNING: $SHGSI_SMALLICON: possibly used before declaration.
   $tIcon = _WinAPI_ShellGetStockIconInfo($ID[$i], BitOR($SHGSI_ICON, $SHGSI_SMALLICON)
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersstefanoDocumentsprogrammazioneUDF-AGGIUNTIVETVExplorerTVExplorer.au3(1404,28) : WARNING: $SIID_DRIVEFIXED: possibly used before declaration.
  $ID[0] = $SIID_DRIVEFIXED
  ~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersstefanoDocumentsprogrammazioneUDF-AGGIUNTIVETVExplorerTVExplorer.au3(1405,29) : WARNING: $SIID_DRIVEREMOVE: possibly used before declaration.
  $ID[1] = $SIID_DRIVEREMOVE
  ~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersstefanoDocumentsprogrammazioneUDF-AGGIUNTIVETVExplorerTVExplorer.au3(1406,26) : WARNING: $SIID_DRIVERAM: possibly used before declaration.
  $ID[2] = $SIID_DRIVERAM
  ~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersstefanoDocumentsprogrammazioneUDF-AGGIUNTIVETVExplorerTVExplorer.au3(1407,25) : WARNING: $SIID_DRIVECD: possibly used before declaration.
  $ID[3] = $SIID_DRIVECD
  ~~~~~~~~~~~~~~~~~~~~~~^
C:UsersstefanoDocumentsprogrammazioneUDF-AGGIUNTIVETVExplorerTVExplorer.au3(1408,26) : WARNING: $SIID_DRIVENET: possibly used before declaration.
  $ID[4] = $SIID_DRIVENET
  ~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersstefanoDocumentsprogrammazioneUDF-AGGIUNTIVETVExplorerTVExplorer.au3(833,66) : ERROR: $SEM_FAILCRITICALERRORS: undeclared global variable.
Local $Mode = _WinAPI_SetErrorMode(BitOR($SEM_FAILCRITICALERRORS,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersstefanoDocumentsprogrammazioneUDF-AGGIUNTIVETVExplorerTVExplorer.au3(833,91) : ERROR: $SEM_NOOPENFILEERRORBOX: undeclared global variable.
Local $Mode = _WinAPI_SetErrorMode(BitOR($SEM_FAILCRITICALERRORS, $SEM_NOOPENFILEERRORBOX)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersstefanoDocumentsprogrammazioneUDF-AGGIUNTIVETVExplorerTVExplorer.au3(945,39) : ERROR: $SHGFI_SMALLICON: undeclared global variable.
Local $Flags = BitOR($SHGFI_SMALLICON,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersstefanoDocumentsprogrammazioneUDF-AGGIUNTIVETVExplorerTVExplorer.au3(945,60) : ERROR: $SHGFI_SYSICONINDEX: undeclared global variable.
Local $Flags = BitOR($SHGFI_SMALLICON, $SHGFI_SYSICONINDEX)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersstefanoDocumentsprogrammazioneUDF-AGGIUNTIVETVExplorerTVExplorer.au3(949,33) : ERROR: $SHGFI_OPENICON: undeclared global variable.
  $Flags = BitOR($SHGFI_OPENICON,
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersstefanoDocumentsprogrammazioneUDF-AGGIUNTIVETVExplorerTVExplorer.au3(994,61) : ERROR: $SHGFI_ICON: undeclared global variable.
   $hIL = _WinAPI_ShellGetFileInfo($sPath, BitOR($SHGFI_ICON,
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersstefanoDocumentsprogrammazioneUDF-AGGIUNTIVETVExplorerTVExplorer.au3(994,82) : ERROR: $SHGFI_OVERLAYINDEX: undeclared global variable.
   $hIL = _WinAPI_ShellGetFileInfo($sPath, BitOR($SHGFI_ICON, $SHGFI_OVERLAYINDEX,
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersstefanoDocumentsprogrammazioneUDF-AGGIUNTIVETVExplorerTVExplorer.au3(994,108) : ERROR: $SHGFI_USEFILEATTRIBUTES: undeclared global variable.
   $hIL = _WinAPI_ShellGetFileInfo($sPath, BitOR($SHGFI_ICON, $SHGFI_OVERLAYINDEX, $SHGFI_USEFILEATTRIBUTES,
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersstefanoDocumentsprogrammazioneUDF-AGGIUNTIVETVExplorerTVExplorer.au3(1082,40) : ERROR: $SSF_SHOWALLOBJECTS: undeclared global variable.
Local $Param[3] = [$SSF_SHOWALLOBJECTS,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersstefanoDocumentsprogrammazioneUDF-AGGIUNTIVETVExplorerTVExplorer.au3(1082,64) : ERROR: $SSF_SHOWEXTENSIONS: undeclared global variable.
Local $Param[3] = [$SSF_SHOWALLOBJECTS, 0, $SSF_SHOWEXTENSIONS]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersstefanoDocumentsprogrammazioneUDF-AGGIUNTIVETVExplorerTVExplorer.au3(1362,28) : ERROR: $SIID_DOCNOASSOC: undeclared global variable.
  $ID[0] = $SIID_DOCNOASSOC
  ~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersstefanoDocumentsprogrammazioneUDF-AGGIUNTIVETVExplorerTVExplorer.au3(1363,24) : ERROR: $SIID_FOLDER: undeclared global variable.
  $ID[1] = $SIID_FOLDER
  ~~~~~~~~~~~~~~~~~~~~~^
C:UsersstefanoDocumentsprogrammazioneUDF-AGGIUNTIVETVExplorerTVExplorer.au3(1364,28) : ERROR: $SIID_FOLDEROPEN: undeclared global variable.
  $ID[2] = $SIID_FOLDEROPEN
  ~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersstefanoDocumentsprogrammazioneUDF-AGGIUNTIVETVExplorerTVExplorer.au3(1366,69) : ERROR: $SHGSI_ICON: undeclared global variable.
   $tIcon = _WinAPI_ShellGetStockIconInfo($ID[$i], BitOR($SHGSI_ICON,
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersstefanoDocumentsprogrammazioneUDF-AGGIUNTIVETVExplorerTVExplorer.au3(1366,87) : ERROR: $SHGSI_SMALLICON: undeclared global variable.
   $tIcon = _WinAPI_ShellGetStockIconInfo($ID[$i], BitOR($SHGSI_ICON, $SHGSI_SMALLICON)
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersstefanoDocumentsprogrammazioneUDF-AGGIUNTIVETVExplorerTVExplorer.au3(1404,28) : ERROR: $SIID_DRIVEFIXED: undeclared global variable.
  $ID[0] = $SIID_DRIVEFIXED
  ~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersstefanoDocumentsprogrammazioneUDF-AGGIUNTIVETVExplorerTVExplorer.au3(1405,29) : ERROR: $SIID_DRIVEREMOVE: undeclared global variable.
  $ID[1] = $SIID_DRIVEREMOVE
  ~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersstefanoDocumentsprogrammazioneUDF-AGGIUNTIVETVExplorerTVExplorer.au3(1406,26) : ERROR: $SIID_DRIVERAM: undeclared global variable.
  $ID[2] = $SIID_DRIVERAM
  ~~~~~~~~~~~~~~~~~~~~~~~^
C:UsersstefanoDocumentsprogrammazioneUDF-AGGIUNTIVETVExplorerTVExplorer.au3(1407,25) : ERROR: $SIID_DRIVECD: undeclared global variable.
  $ID[3] = $SIID_DRIVECD
  ~~~~~~~~~~~~~~~~~~~~~~^
Link to comment
Share on other sites

i use this example for understund

#Include <GUIConstantsEx.au3>
#Include <GUITreeView.au3>
#Include <TVExplorer.au3>
#Include <TreeViewConstants.au3>
#Include <WindowsConstants.au3>
#Include <WinAPIEx.au3>
;Opt('MustDeclareVars', 1)
Global $hForm, $hTV[3], $Input[3], $hFocus = 0, $Dummy, $Path, $Style
If Not _WinAPI_DwmIsCompositionEnabled() Then
    $Style = $WS_EX_COMPOSITED
Else
    $Style = -1
EndIf
$hForm = GUICreate('TVExplorer UDF Example', 700, 736, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX), $Style)
GUISetIcon(@WindowsDir & 'explorer.exe')
$Input[0] = GUICtrlCreateInput('', 20, 20, 320, 19)
GUICtrlSetState(-1, $GUI_DISABLE)
$hTV[0] = _GUICtrlTVExplorer_Create(@ProgramFilesDir, 20, 48, 320, 310, -1, $WS_EX_CLIENTEDGE, -1, '_TVEvent')
$Input[1] = GUICtrlCreateInput('', 360, 20, 320, 19)
GUICtrlSetState(-1, $GUI_DISABLE)
$hTV[1] = _GUICtrlTVExplorer_Create(@UserProfileDir, 360, 48, 320, 310, -1, $WS_EX_CLIENTEDGE, -1, '_TVEvent')
$Input[2] = GUICtrlCreateInput('', 20, 378, 660, 19)
GUICtrlSetState(-1, $GUI_DISABLE)
$hTV[2] = _GUICtrlTVExplorer_Create('', 20, 406, 660, 310, -1, $WS_EX_CLIENTEDGE, -1, '_TVEvent')
For $i = 0 To 2
    _TVSetPath($Input[$i], _GUICtrlTVExplorer_GetSelected($hTV[$i]))
    _GUICtrlTVExplorer_SetExplorerStyle($hTV[$i])
Next
$Dummy = GUICtrlCreateDummy()
GUIRegisterMsg($WM_GETMINMAXINFO, 'WM_GETMINMAXINFO')
GUIRegisterMsg($WM_SIZE, 'WM_SIZE')
HotKeySet('{F5}', '_TVRefresh')
GUISetState()
_GUICtrlTVExplorer_Expand($hTV[0], @ProgramFilesDir & 'AutoIt3')
_GUICtrlTVExplorer_Expand($hTV[1])
While 1
    Switch _GUICtrlTVExplorer_GetMsg()
        Case $GUI_EVENT_CLOSE
            GUIDelete()
            _GUICtrlTVExplorer_DestroyAll()
            Exit
        Case $Dummy
            $Path = _GUICtrlTVExplorer_GetSelected($hFocus)
            _GUICtrlTVExplorer_AttachFolder($hFocus)
            _GUICtrlTVExplorer_Expand($hFocus, $Path, 0)
            $hFocus = 0
    EndSwitch
WEnd
Func _TVEvent($hWnd, $iMsg, $sPath, $hItem)
    Switch $iMsg
        Case $TV_NOTIFY_BEGINUPDATE
            GUISetCursor(1, 1)
        Case $TV_NOTIFY_ENDUPDATE
            GUISetCursor(2)
        Case $TV_NOTIFY_SELCHANGED
            For $i = 0 To 2
                If $hTV[$i] = $hWnd Then
                    _TVSetPath($Input[$i], $sPath)
                    ExitLoop
                EndIf
            Next
        Case $TV_NOTIFY_DBLCLK
            ; Nothing
        Case $TV_NOTIFY_RCLICK
            ; Nothing
        Case $TV_NOTIFY_DELETINGITEM
            ; Nothing
        Case $TV_NOTIFY_DISKMOUNTED
            ; Nothing
        Case $TV_NOTIFY_DISKUNMOUNTED
            ; Nothing
    EndSwitch
EndFunc   ;==>_TVEvent
Func _TVSetPath($iInput, $sPath)
    Local $Text = _WinAPI_PathCompactPath(GUICtrlGetHandle($iInput), $sPath, -2)
    If GUICtrlRead($iInput) <> $Text Then
        GUICtrlSetData($iInput, $Text)
    EndIf
EndFunc   ;==>_TVSetPath
Func _TVRefresh()
    Local $hWnd = _WinAPI_GetFocus()
    For $i = 0 To 2
        If $hTV[$i] = $hWnd Then
            If Not $hFocus Then
                $hFocus = $hWnd
                GUICtrlSendToDummy($Dummy)
            EndIf
            Return
        EndIf
    Next
    HotKeySet('{F5}')
    Send('{F5}')
    HotKeySet('{F5}', '_TVRefresh')
EndFunc   ;==>_TVRefresh
Func WM_GETMINMAXINFO($hWnd, $iMsg, $wParam, $lParam)
    Local $tMMI = DllStructCreate('long Reserved[2];long MaxSize[2];long MaxPosition[2];long MinTrackSize[2];long MaxTrackSize[2]', $lParam)
    Switch $hWnd
        Case $hForm
            DllStructSetData($tMMI, 'MinTrackSize', 428, 1)
            DllStructSetData($tMMI, 'MinTrackSize', 450, 2)
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_GETMINMAXINFO
Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam)
    Local $WC, $HC, $WT, $HT
    Switch $hWnd
        Case $hForm
            $WC = _WinAPI_LoWord($lParam)
            $HC = _WinAPI_HiWord($lParam)
            $WT = Floor(($WC - 60) / 2)
            $HT = Floor(($HC - 116) / 2)
            GUICtrlSetPos(_WinAPI_GetDlgCtrlID($hTV[0]), 20, 48, $WT, $HT)
            GUICtrlSetPos(_WinAPI_GetDlgCtrlID($hTV[1]), $WT + 40, 48, $WC - $WT - 60, $HT)
            GUICtrlSetPos(_WinAPI_GetDlgCtrlID($hTV[2]), 20, $HT + 96, $WC - 40, $HC - $HT - 116)
            GUICtrlSetPos($Input[0], 20, 20, $WT)
            GUICtrlSetPos($Input[1], $WT + 40, 20, $WC - $WT - 60)
            GUICtrlSetPos($Input[2], 20, $HT + 68, $WC - 40)
            For $i = 0 To 2
                _TVSetPath($Input[$i], _GUICtrlTVExplorer_GetSelected($hTV[$i]))
            Next
            Return 0
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_SIZE
Link to comment
Share on other sites

Link to comment
Share on other sites

i have a little problem

i use the example and modd for my prog (long prog ufffff)

but tell me variable used whit out begin declered

but i had declered

this is a part of my script

Global $hForm, $hTreeView, $hImageList, $hItem, $hNext, $hSelect = 0, $hInput, $Input, $Dummy1, $Dummy2
Global $X, $Y, $sPath,
Global $sRoot
$sRoot=$percorso_progetto&''&$nome_pogetto&
Func _test()
$hTreeView = GUICtrlGetHandle(-1)
$Dummy1 = GUICtrlCreateDummy()
$Dummy2 = GUICtrlCreateDummy()
If _WinAPI_GetVersion() >= '6.0' Then
    _WinAPI_SetWindowTheme($hTreeView, 'Explorer')
EndIf
$hImageList = _GUIImageList_Create(16, 16, 5, 1)
_GUIImageList_AddIcon($hImageList, @SystemDir & 'shell32.dll', 3)
_GUIImageList_AddIcon($hImageList, @SystemDir & 'shell32.dll', 4)
_GUICtrlTreeView_SetNormalImageList($hTreeView, $hImageList)
$sRoot = StringRegExpReplace($sRoot, '+Z', '')
$sPath = StringRegExpReplace($sRoot, '^.*', '')
If StringInStr($sPath, ':') Then
    $sRoot &= ''
    $sPath &= ''
EndIf
;_GUICtrlTreeView_BeginUpdate($hTreeView)
_TVUpdate($hTreeView, _GUICtrlTreeView_AddChild($hTreeView, 0, $sPath, 0, 0))
;_GUICtrlTreeView_EndUpdate($hTreeView)
GUIRegisterMsg($WM_NOTIFY, 'WM_NOTIFY')
GUISetState()
_GUICtrlTreeView_Expand($hTreeView, _GUICtrlTreeView_GetFirstItem($hTreeView))
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Dummy1 ; Update
            GUISetCursor(1, 1)
            $hItem = _GUICtrlTreeView_GetFirstChild($hTreeView, GUICtrlRead($Dummy1))
            If $hItem Then
                While $hItem
                    $hNext = _GUICtrlTreeView_GetNextSibling($hTreeView, $hItem)
                    If Not _TVUpdate($hTreeView, $hItem) Then
                        _GUICtrlTreeView_Delete($hTreeView, $hItem)
                    EndIf
                    $hItem = $hNext
                WEnd
                _WinAPI_RedrawWindow($hTreeView)
            EndIf
            GUISetCursor(2, 0)
        Case $Dummy2 ; Menu
            $hItem = GUICtrlRead($Dummy2)
            $sPath = _TVGetPath($hTreeView, $hItem, $sRoot)
            ConsoleWrite('-------------------------------' & @CR)
            ConsoleWrite('Handle: ' & $hItem & @CR)
            ConsoleWrite('Path:   ' & $sPath & @CR)
            If _WinAPI_PathIsDirectory($sPath) Then
                ConsoleWrite('Type:   ' & 'Directory' & @CR)
            Else
                ConsoleWrite('Type:   ' & 'File' & @CR)
            EndIf
            ConsoleWrite('X:      ' & MouseGetPos(0) & @CR)
            ConsoleWrite('Y:      ' & MouseGetPos(1) & @CR)
            ConsoleWrite('-------------------------------' & @CR)
    EndSwitch
WEnd
EndFunc

Func _TVGetPath($hTV, $hItem, $sRoot)
    Local $Path = StringRegExpReplace(_GUICtrlTreeView_GetTree($hTV, $hItem), '([|]+)|([|])', '')
    If Not $Path Then
        Return ''
    EndIf
    If Not StringInStr($Path, ':') Then
        Return StringRegExpReplace($sRoot, '([^]*(|)+)Z', '') & $Path
    EndIf
    Return $Path
EndFunc   ;==>_TVGetPath
Func _TVSetPath($hTV, $hItem, $sRoot)
    GUICtrlSetData($Input, _WinAPI_PathCompactPath($hInput, _TVGetPath($hTV, $hItem, $sRoot), 554))
    $hSelect = $hItem
EndFunc   ;==>_TVSetPath
Func _TVUpdate($hTV, $hItem)
    Local $hImageList = _SendMessage($hTV, $TVM_GETIMAGELIST)
    Local $Path = StringRegExpReplace(_TVGetPath($hTV, $hItem, $sRoot), '+Z', '')
    Local $hSearch, $hIcon, $Index, $File
    $hSearch = FileFindFirstFile($Path & '*')
    If $hSearch = -1 Then
        If Not @error Then
            If FileExists($Path) Then
;              If _WinAPI_PathIsDirectory($Path) Then
;                  ; Access denied
;              EndIf
            Else
                Return 0
            EndIf
        EndIf
    Else
        While 1
            $File = FileFindNextFile($hSearch)
            If @error Then
                ExitLoop
            EndIf
            If @extended Then
                _GUICtrlTreeView_AddChild($hTV, $hItem, $File, 0, 0)
            EndIf
        WEnd
        FileClose($hSearch)
    EndIf
    $hSearch = FileFindFirstFile($Path & '*')
    If $hSearch = -1 Then
    Else
        While 1
            $File = FileFindNextFile($hSearch)
            If @error Then
                ExitLoop
            EndIf
            If Not @extended Then
                $hIcon = _WinAPI_ShellExtractAssociatedIcon($Path & '' & $File, 1)
                $Index = _GUIImageList_ReplaceIcon($hImageList, -1, $hIcon)
                _GUICtrlTreeView_AddChild($hTV, $hItem, $File, $Index, $Index)
                _WinAPI_DestroyIcon($hIcon)
            EndIf
        WEnd
        FileClose($hSearch)
    EndIf
    Return 1
EndFunc   ;==>_TVUpdate
Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    Local $tNMTREEVIEW = DllStructCreate($tagNMTREEVIEW, $lParam)
    Local $hItem = DllStructGetData($tNMTREEVIEW, 'NewhItem')
    Local $iState = DllStructGetData($tNMTREEVIEW, 'NewState')
    Local $hTV = DllStructGetData($tNMTREEVIEW, 'hWndFrom')
    Local $ID = DllStructGetData($tNMTREEVIEW, 'Code')
    Local $tTVHTI, $tPoint
    Switch $hTV
        Case $hTreeView
            Switch $ID
                Case $TVN_ITEMEXPANDEDW
                    If Not FileExists(_TVGetPath($hTV, $hItem, $sRoot)) Then
                        _GUICtrlTreeView_Delete($hTV, $hItem)
                        If BitAND($iState, $TVIS_SELECTED) Then
                            _TVSetPath($hTV, _GUICtrlTreeView_GetSelection($hTV), $sRoot)
                        EndIf
                    Else
                        If Not BitAND($iState, $TVIS_EXPANDED) Then
                            _GUICtrlTreeView_SetSelectedImageIndex($hTV, $hItem, 0)
                            _GUICtrlTreeView_SetImageIndex($hTV, $hItem, 0)
                        Else
                            _GUICtrlTreeView_SetSelectedImageIndex($hTV, $hItem, 1)
                            _GUICtrlTreeView_SetImageIndex($hTV, $hItem, 1)
                            If Not _GUICtrlTreeView_GetItemParam($hTV, $hItem) Then
                                _GUICtrlTreeView_SetItemParam($hTV, $hItem, 0x7FFFFFFF)
                                GUICtrlSendToDummy($Dummy1, $hItem)
                            EndIf
                        EndIf
                    EndIf
                Case $TVN_SELCHANGEDW
                    If BitAND($iState, $TVIS_SELECTED) Then
                        If Not FileExists(_TVGetPath($hTV, $hItem, $sRoot)) Then
                            _GUICtrlTreeView_Delete($hTV, $hItem)
                            $hItem = _GUICtrlTreeView_GetSelection($hTV)
                        EndIf
                        If $hItem <> $hSelect Then
                            _TVSetPath($hTV, $hItem, $sRoot)
                        EndIf
                    EndIf
                Case $NM_RCLICK
                        $tPoint = _WinAPI_GetMousePos(1, $hTV)
                        $tTVHTI = _GUICtrlTreeView_HitTestEx($hTV, DllStructGetData($tPoint, 1), DllStructGetData($tPoint, 2))
                        $hItem = DllStructGetData($tTVHTI, 'Item')
                        If BitAND(DllStructGetData($tTVHTI, 'Flags'), $TVHT_ONITEM) Then
                            _GUICtrlTreeView_SelectItem($hTreeView, $hItem)
                            If Not FileExists(_TVGetPath($hTV, $hItem, $sRoot)) Then
                                _GUICtrlTreeView_Delete($hTV, $hItem)
                                $hItem = _GUICtrlTreeView_GetSelection($hTV)
                            Else
                                GUICtrlSendToDummy($Dummy2, $hItem)
                            EndIf
                            If $hItem <> $hSelect Then
                                _TVSetPath($hTV, $hItem, $sRoot)
                            EndIf
                        EndIf
                EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY
Link to comment
Share on other sites

>Running:(3.3.8.1):C:Program Files (x86)AutoIt3autoit3.exe "C:UsersstefanoDocumentsprogrammazioneXUL-STUDIOXUL-STUDIO-versione1.au3"   
C:UsersstefanoDocumentsprogrammazioneXUL-STUDIOXUL-STUDIO-versione1.au3 (356) : ==> Variable used without being declared.:
$sRoot = StringRegExpReplace($sRoot1, '+Z', '')
$sRoot = StringRegExpReplace(^ ERROR
->21:17:20 AutoIT3.exe ended.rc:1
>Exit code: 1    Time: 18.459

Link to comment
Share on other sites

$sRoot1, shouldn't that be $sRoot?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

o o no $root is the same problem i had tryed to do some changed but give me the same problem

C:UsersstefanoDocumentsprogrammazioneXUL-STUDIOXUL-STUDIO-versione1.au3 (355) : ==> Variable used without being declared.:
$sRoot = StringRegExpReplace($sRoot, '+Z', '')
$sRoot = StringRegExpReplace(^ ERROR
->21:43:01 AutoIT3.exe ended.rc:1
>Exit code: 1    Time: 18.755
Link to comment
Share on other sites

Then I'd need to see the whole script, because what you posted shows $sRoot being declared as a Global variable at the top of the snippet you posted so it makes no sense why you'd get that error message.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...