Jump to content
Sign in to follow this  
Yashied

TVExplorer UDF

Recommended Posts

Yashied I forgot some code in the main while loop.

here is the final one. Sorry...

;; Valuater
#include <GuiConstants.au3>
#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <GuiComboBox.au3>
#include "include\TVExplorer.au3"

Dim $show = 0, $Child_[11], $children = 10, $ChildActual = 1
Global $Control_1[10]
Global $Control_2[10]
Global $Control_3[10]
Global $Control_4[10]
Global $Control_5[10]
Global $Control_6[10]
Global $Control_7[10]
Global $Control_8[10]
Global $Control_9[10]
Global $Control_10[10]

Global $hFocus = 0

$Main = GUICreate("New Link Wizard", 548, 360, (@DesktopWidth - 516) / 2, (@DesktopHeight - 323) / 2, -1, -1)

$Button_1 = GUICtrlCreateButton("&Next >", 20, 150, 80, 25)
$Button_2 = GUICtrlCreateButton("< &Back", 20, 120, 80, 25)
$Button_3 = GUICtrlCreateButton("&Exit", 20, 300, 80, 25)

GUISetState()

$Child_[1] = GUICreate("", 540, 330, 0, 0, BitOR($WS_CHILD, $WS_TABSTOP) + $WS_DLGFRAME, -1, $Main)
_Form_1($Control_1)
GUISetState()

$Child_[2] = GUICreate("", 540, 330, 0, 0, BitOR($WS_CHILD, $WS_TABSTOP) + $WS_DLGFRAME, -1, $Main)
_Form_2($Control_2)
GUISetState(@SW_HIDE)

$Child_[3] = GUICreate("", 540, 330, 0, 0, BitOR($WS_CHILD, $WS_TABSTOP) + $WS_DLGFRAME, -1, $Main)
_Form_3($Control_3)
GUISetState(@SW_HIDE)

$Child_[4] = GUICreate("", 540, 330, 0, 0, BitOR($WS_CHILD, $WS_TABSTOP) + $WS_DLGFRAME, -1, $Main)
_Form_4($Control_4)
GUISetState(@SW_HIDE)

$Child_[5] = GUICreate("", 540, 330, 0, 0, BitOR($WS_CHILD, $WS_TABSTOP) + $WS_DLGFRAME, -1, $Main)
_Form_5($Control_5)
GUISetState(@SW_HIDE)

$Child_[6] = GUICreate("", 540, 330, 0, 0, BitOR($WS_CHILD, $WS_TABSTOP) + $WS_DLGFRAME, -1, $Main)
_Form_6($Control_6)
GUISetState(@SW_HIDE)

$Child_[7] = GUICreate("", 540, 330, 0, 0, BitOR($WS_CHILD, $WS_TABSTOP) + $WS_DLGFRAME, -1, $Main)
_Form_7($Control_7)
GUISetState(@SW_HIDE)

$Child_[8] = GUICreate("", 540, 330, 0, 0, BitOR($WS_CHILD, $WS_TABSTOP) + $WS_DLGFRAME, -1, $Main)
_Form_8($Control_8)
GUISetState(@SW_HIDE)

$Child_[9] = GUICreate("", 540, 330, 0, 0, BitOR($WS_CHILD, $WS_TABSTOP) + $WS_DLGFRAME, -1, $Main)
_Form_9($Control_9)
GUISetState(@SW_HIDE)

$Child_[10] = GUICreate("", 540, 330, 0, 0, BitOR($WS_CHILD, $WS_TABSTOP) + $WS_DLGFRAME, -1, $Main)
_Form_10($Control_10)

GUISetState(@SW_HIDE)

While 1
    $msg = GUIGetMsg(1)

    Switch $msg[1]
        Case $Main
            Switch $msg[0]
                Case $GUI_EVENT_CLOSE
                    ExitLoop
                Case $Button_3
                    ExitLoop
                Case $Button_1
                    Set_ChildSwitch(+1)
                Case $Button_2
                    Set_ChildSwitch(-1)
            EndSwitch
        Case $Child_[2]
            Switch $msg[0]
                Case $Control_2[0]
                    $Path = _GUICtrlTVExplorer_GetSelected($hFocus)
                    _GUICtrlTVExplorer_AttachFolder($hFocus)
                    _GUICtrlTVExplorer_Expand($hFocus, $Path, 0)
                    $hFocus = 0
            EndSwitch
    EndSwitch
WEnd

GUIDelete($Main)
;--------- Functions -------------------

Func Set_ChildSwitch($ud)
    GUISetState(@SW_HIDE, $Child_[$ChildActual])
    $ChildActual += $ud
    If $ChildActual = 11 Then $ChildActual = 1
    If $ChildActual = 0 Then $ChildActual = 10
    GUISetState(@SW_SHOW, $Child_[$ChildActual])
EndFunc   ;==>Set_ChildSwitch

Func _Form_1(ByRef $Control_1)

EndFunc   ;==>_Form_1

Func _Form_2(ByRef $Control_2)
    $Control_2[0] = _GUICtrlTVExplorer_Create(@ProgramFilesDir, 320, 48, 200, 210, -1, $WS_EX_CLIENTEDGE, -1, '_TVEvent')
    $Control_2[1] = GUICtrlCreateDummy()
    HotKeySet('{F5}', '_TVRefresh')
    _GUICtrlTVExplorer_Expand($Control_2[0], @ProgramFilesDir & '\AutoIt3')
    _GUICtrlTVExplorer_Expand($Control_2[0])
    $Control_2[2] = GUICtrlCreateInput("", 320, 20, 200, 20)
EndFunc   ;==>_Form_2

Func _Form_3(ByRef $Control_3)

EndFunc   ;==>_Form_3

Func _Form_4(ByRef $Control_4)

EndFunc   ;==>_Form_4

Func _Form_5(ByRef $Control_5)

EndFunc   ;==>_Form_5

Func _Form_6(ByRef $Control_6)

EndFunc   ;==>_Form_6

Func _Form_7(ByRef $Control_7)

EndFunc   ;==>_Form_7

Func _Form_8(ByRef $Control_8)

EndFunc   ;==>_Form_8

Func _Form_9(ByRef $Control_9)

EndFunc   ;==>_Form_9

Func _Form_10(ByRef $Control_10)

EndFunc   ;==>_Form_10

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()
    If $Control_2[0] = $hWnd Then
        If Not $hFocus Then
            $hFocus = $hWnd
            GUICtrlSendToDummy($Control_2[1])
        EndIf
        Return
    EndIf
    HotKeySet('{F5}')
    Send('{F5}')
    HotKeySet('{F5}', '_TVRefresh')
EndFunc   ;==>_TVRefresh

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
            If $Control_2[0] = $hWnd Then
                _TVSetPath($Control_2[2], $sPath)
            EndIf
        Case $TV_NOTIFY_DBLCLK
        Case $TV_NOTIFY_RCLICK
            ; Nothing
        Case $TV_NOTIFY_DELETINGITEM
            ; Nothing
        Case $TV_NOTIFY_DISKMOUNTED
            ; Nothing
        Case $TV_NOTIFY_DISKUNMOUNTED
            ; Nothing
    EndSwitch
EndFunc   ;==>_TVEvent

Be Green Now or Never (BGNN)!

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

Just replace GUIGetMsg(1) to _GUICtrlTVExplorer_GetMsg(1) or use OnEvent mode. I wrote about it in the first post.

Yashied, thanks. This solve the example that I posted, however in my real application I have WM_NOTIFY function

that cause the same symptom.

Here is the code that is not working even after I put your correction.

;; Valuater
#include <GuiConstants.au3>
#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <GuiComboBox.au3>
#include "include\TVExplorer.au3"
#include <GuiRichEdit.au3>
Dim $show = 0, $Child_[11], $children = 10, $ChildActual = 1
Global $Control_1[10]
Global $Control_2[10]
Global $Control_3[10]
Global $Control_4[10]
Global $Control_5[10]
Global $Control_6[10]
Global $Control_7[10]
Global $Control_8[10]
Global $Control_9[10]
Global $Control_10[10]

Global $hFocus = 0

$Main = GUICreate("New Link Wizard", 548, 360, (@DesktopWidth - 516) / 2, (@DesktopHeight - 323) / 2, -1, -1)

$Button_1 = GUICtrlCreateButton("&Next >", 20, 150, 80, 25)
$Button_2 = GUICtrlCreateButton("< &Back", 20, 120, 80, 25)
$Button_3 = GUICtrlCreateButton("&Exit", 20, 300, 80, 25)

GUISetState()

$Child_[1] = GUICreate("", 540, 330, 0, 0, BitOR($WS_CHILD, $WS_TABSTOP) + $WS_DLGFRAME, -1, $Main)
_Form_1($Control_1)
GUISetState()

$Child_[2] = GUICreate("", 540, 330, 0, 0, BitOR($WS_CHILD, $WS_TABSTOP) + $WS_DLGFRAME, -1, $Main)
_Form_2($Control_2)
GUISetState(@SW_HIDE)

$Child_[3] = GUICreate("", 540, 330, 0, 0, BitOR($WS_CHILD, $WS_TABSTOP) + $WS_DLGFRAME, -1, $Main)
_Form_3($Control_3)
GUISetState(@SW_HIDE)

$Child_[4] = GUICreate("", 540, 330, 0, 0, BitOR($WS_CHILD, $WS_TABSTOP) + $WS_DLGFRAME, -1, $Main)
_Form_4($Control_4)
GUISetState(@SW_HIDE)

$Child_[5] = GUICreate("", 540, 330, 0, 0, BitOR($WS_CHILD, $WS_TABSTOP) + $WS_DLGFRAME, -1, $Main)
_Form_5($Control_5)
GUISetState(@SW_HIDE)

$Child_[6] = GUICreate("", 540, 330, 0, 0, BitOR($WS_CHILD, $WS_TABSTOP) + $WS_DLGFRAME, -1, $Main)
_Form_6($Control_6)
GUISetState(@SW_HIDE)

$Child_[7] = GUICreate("", 540, 330, 0, 0, BitOR($WS_CHILD, $WS_TABSTOP) + $WS_DLGFRAME, -1, $Main)
_Form_7($Control_7)
GUISetState(@SW_HIDE)

$Child_[8] = GUICreate("", 540, 330, 0, 0, BitOR($WS_CHILD, $WS_TABSTOP) + $WS_DLGFRAME, -1, $Main)
_Form_8($Control_8)
GUISetState(@SW_HIDE)

$Child_[9] = GUICreate("", 540, 330, 0, 0, BitOR($WS_CHILD, $WS_TABSTOP) + $WS_DLGFRAME, -1, $Main)
_Form_9($Control_9)
GUISetState(@SW_HIDE)

$Child_[10] = GUICreate("", 540, 330, 0, 0, BitOR($WS_CHILD, $WS_TABSTOP) + $WS_DLGFRAME, -1, $Main)
_Form_10($Control_10)

GUISetState(@SW_HIDE)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
While 1
    $msg = _GUICtrlTVExplorer_GetMsg(1)

    Switch $msg[1]
        Case $Main
            Switch $msg[0]
                Case $GUI_EVENT_CLOSE
                    ExitLoop
                Case $Button_3
                    ExitLoop
                Case $Button_1
                    Set_ChildSwitch(+1)
                Case $Button_2
                    Set_ChildSwitch(-1)
            EndSwitch
        Case $Child_[2]
            Switch $msg[0]
                Case $Control_2[0]
                    $Path = _GUICtrlTVExplorer_GetSelected($hFocus)
                    _GUICtrlTVExplorer_AttachFolder($hFocus)
                    _GUICtrlTVExplorer_Expand($hFocus, $Path, 0)
                    $hFocus = 0
            EndSwitch
    EndSwitch
WEnd

GUIDelete($Main)
;--------- Functions -------------------

Func Set_ChildSwitch($ud)
    GUISetState(@SW_HIDE, $Child_[$ChildActual])
    $ChildActual += $ud
    If $ChildActual = 11 Then $ChildActual = 1
    If $ChildActual = 0 Then $ChildActual = 10
    GUISetState(@SW_SHOW, $Child_[$ChildActual])
EndFunc   ;==>Set_ChildSwitch

Func _Form_1(ByRef $Control_1)
$Control_1[0] = GuiCtrlCreateButton("Button",20,20,40,22)
EndFunc   ;==>_Form_1

Func _Form_2(ByRef $Control_2)
    $Control_2[0] = _GUICtrlTVExplorer_Create(@ProgramFilesDir, 320, 48, 200, 210, -1, $WS_EX_CLIENTEDGE, -1, '_TVEvent')
    $Control_2[1] = GUICtrlCreateDummy()
    HotKeySet('{F5}', '_TVRefresh')
    _GUICtrlTVExplorer_Expand($Control_2[0], @ProgramFilesDir & '\AutoIt3')
    _GUICtrlTVExplorer_Expand($Control_2[0])
    $Control_2[2] = GUICtrlCreateInput("", 320, 20, 200, 20)
EndFunc   ;==>_Form_2

Func _Form_3(ByRef $Control_3)

EndFunc   ;==>_Form_3

Func _Form_4(ByRef $Control_4)

EndFunc   ;==>_Form_4

Func _Form_5(ByRef $Control_5)

EndFunc   ;==>_Form_5

Func _Form_6(ByRef $Control_6)

EndFunc   ;==>_Form_6

Func _Form_7(ByRef $Control_7)

EndFunc   ;==>_Form_7

Func _Form_8(ByRef $Control_8)

EndFunc   ;==>_Form_8

Func _Form_9(ByRef $Control_9)

EndFunc   ;==>_Form_9

Func _Form_10(ByRef $Control_10)

EndFunc   ;==>_Form_10

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()
    If $Control_2[0] = $hWnd Then
        If Not $hFocus Then
            $hFocus = $hWnd
            GUICtrlSendToDummy($Control_2[1])
        EndIf
        Return
    EndIf
    HotKeySet('{F5}')
    Send('{F5}')
    HotKeySet('{F5}', '_TVRefresh')
EndFunc   ;==>_TVRefresh

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
            If $Control_2[0] = $hWnd Then
                _TVSetPath($Control_2[2], $sPath)
            EndIf
        Case $TV_NOTIFY_DBLCLK
        Case $TV_NOTIFY_RCLICK
            ; Nothing
        Case $TV_NOTIFY_DELETINGITEM
            ; Nothing
        Case $TV_NOTIFY_DISKMOUNTED
            ; Nothing
        Case $TV_NOTIFY_DISKUNMOUNTED
            ; Nothing
    EndSwitch
EndFunc   ;==>_TVEvent

Func WM_NOTIFY($hWnd, $iMsg, $iWparam, $iLparam)
    #forceref $iMsg, $iWparam
    Local $hWndFrom, $iCode, $tNMHDR, $tMsgFilter, $hMenu
    $tNMHDR = DllStructCreate($tagNMHDR, $iLparam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $Control_1[0]
            Select
                Case $iCode = $EN_MSGFILTER
                    $tMsgFilter = DllStructCreate($tagEN_MSGFILTER, $iLparam)
                    If DllStructGetData($tMsgFilter, "msg") = $WM_RBUTTONUP Then
                    ;   $hMenu = GUICtrlGetHandle($Control_2[21])
                    ;   SetMenuTexts($hWndFrom, $hMenu)
                    ;   _GUICtrlMenu_TrackPopupMenu($hMenu, $hWnd)
                    EndIf
            EndSelect

    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Be Green Now or Never (BGNN)!

Share this post


Link to post
Share on other sites

Func WM_NOTIFY($hWnd, $iMsg, $iWparam, $iLparam)
    #forceref $iMsg, $iWparam

    ; VERY IMPORTANT!!!
    TV_WM_NOTIFY($hWnd, $iMsg, $iWparam, $iLparam)

    Local $hWndFrom, $iCode, $tNMHDR, $tMsgFilter, $hMenu
    $tNMHDR = DllStructCreate($tagNMHDR, $iLparam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $Control_1[0]
            Select
                Case $iCode = $EN_MSGFILTER
                    $tMsgFilter = DllStructCreate($tagEN_MSGFILTER, $iLparam)
                    If DllStructGetData($tMsgFilter, "msg") = $WM_RBUTTONUP Then
                    ;   $hMenu = GUICtrlGetHandle($Control_2[21])
                    ;   SetMenuTexts($hWndFrom, $hMenu)
                    ;   _GUICtrlMenu_TrackPopupMenu($hMenu, $hWnd)
                    EndIf
            EndSelect

    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY


Share this post


Link to post
Share on other sites

Func WM_NOTIFY($hWnd, $iMsg, $iWparam, $iLparam)
    #forceref $iMsg, $iWparam

    ; VERY IMPORTANT!!!
    TV_WM_NOTIFY($hWnd, $iMsg, $iWparam, $iLparam)

    Local $hWndFrom, $iCode, $tNMHDR, $tMsgFilter, $hMenu
    $tNMHDR = DllStructCreate($tagNMHDR, $iLparam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $Control_1[0]
            Select
                Case $iCode = $EN_MSGFILTER
                    $tMsgFilter = DllStructCreate($tagEN_MSGFILTER, $iLparam)
                    If DllStructGetData($tMsgFilter, "msg") = $WM_RBUTTONUP Then
                    ;   $hMenu = GUICtrlGetHandle($Control_2[21])
                    ;   SetMenuTexts($hWndFrom, $hMenu)
                    ;   _GUICtrlMenu_TrackPopupMenu($hMenu, $hWnd)
                    EndIf
            EndSelect

    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Hi Yashied. Billions of billions thanks For sharing and support! :)

Its took me a one night until I noticed your comment inside the WM_NOTIFY. ;)

; VERY IMPORTANT!!!

TV_WM_NOTIFY($hWnd, $iMsg, $iWparam, $iLparam)


Be Green Now or Never (BGNN)!

Share this post


Link to post
Share on other sites

Yashied,

This is nice mode and I realy like it and I am gona use it in my application.

Until now I tested it on Win XP SP3, windows 2003 and windows 2008 all systems 64 BIT and its worked fine.

A little issue I saw is that when using a background picture utilizing GUICtrlCreatePic() under the control then sometimes but not always, when the tree collapsed the picture overlapped the control.

I disabled the GUICtrlCreatePic control and set the TVExplorer control on top but nothing helped.

Like this:

GUICtrlCreatePic("img_bg.bmp", 0, 0, 700, 736)
GUICtrlSetState(-1, $GUI_DISABLE)

GUICtrlSetState($hTV[0], $GUI_FOCUS)

Be Green Now or Never (BGNN)!

Share this post


Link to post
Share on other sites

I have one more question please.

Is it possible to set a different root folder in the control after creating the control?

Something like detaching the tree and creating it with new root.

EDIT: ActuallyI found how to do it with simple case.

_GUICtrlTreeView_Delete($hTV,  0)
GUICtrlTVExplorer_AttachFolder ( hTV , $sPath)
Edited by lsakizada

Be Green Now or Never (BGNN)!

Share this post


Link to post
Share on other sites

Thanks Yashied for an excellent UDF, I've been sitting here wondering how to get two TreeViews into one GUI and next thing I know...problem solved.

Except I'm having a hard time just displaying a Directory Tree, I assume $TV_FLAG_DIRTREE is the flag I want but it seems to only display some directories and not others.

The code is basically the example with all the parts I didn't need stripped out.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_UseX64=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#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, 340, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX), $Style)
GUISetIcon(@WindowsDir & '\explorer.exe')
$hTV[0] = _GUICtrlTVExplorer_Create('', 20, 20, 320, 310, -1, $WS_EX_CLIENTEDGE, $TV_FLAG_DIRTREE, '_TVEvent')
$hTV[1] = _GUICtrlTVExplorer_Create('', 360, 20, 320, 310, -1, $WS_EX_CLIENTEDGE, $TV_FLAG_DEFAULT, '_TVEvent')
For $i = 0 To 1
    _TVSetPath($Input[$i], _GUICtrlTVExplorer_GetSelected($hTV[$i]))
    _GUICtrlTVExplorer_SetExplorerStyle($hTV[$i])
Next
$Dummy = GUICtrlCreateDummy()
GUISetState()

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

Posted Image

What I'd like is the directory tree as per the tree view on the right without files but I can't seem to get it using various combinations of the $TV_FLAG_SHOW* flags.

While I'm using Win7 x64 on my main computer, it also seems to do it on XP Pro SP3 computers I have. It's not just that particular media, (flash drive), either it happens across all my hard drives, ie. some directory structures are there and some don't expand even though I know they go 1 or more levels deep.

So any help getting just a directory tree view that displays all (sub-)directories would be much appreciated.

TVExplorer v1.1

WinAPIEx v3.2

AutoIt v3.3.6.1

Thank you again for a really good UDF.

Share this post


Link to post
Share on other sites

Yashied,

Is it a possible to extract the code from the UDF to get the file's associated icon?

I have been looking around and most of the code that I have seen in the forums was not detected all icons associated with the files on my system.

Apparently that your code is doing it properly.

BTW: I realy like your coding.

Regards!

EDIT: OOOPSS: I just so this link and its works for me.

Edited by lsakizada

Be Green Now or Never (BGNN)!

Share this post


Link to post
Share on other sites

Yasheid,

I had posted a question a couple of weeks ago on the thread about On The Fly TreeViews in the hope that you would see it. But Melba23 suggested that I might want to bring it up on this active thread ... so, my question was this:

I've explored the examples you pointed to and also explored the tree view examples in help. I quickly found that I was reading too much "directory tree" into the purpose and functions of tree views. ... But before I abandon my idea, I wanted to show exactly what I was trying for and ask: is this impossible in a simple script?

Can you suggest a way? I seems to me that many would find this enhanced "on the fly" view useful.

post-29172-0-65407400-1299093103_thumb.p

Share this post


Link to post
Share on other sites

Look at the example for _WinAPI_ShellExtractAssociatedIcon() function from library.

Yashied, thank you very much. I learn the example and implemented it into my application.

Just one thing notice that some icons are displayed properly with your TVExplorer control while the example could not display it well.

for example the link extension (.lnk) display as the windows not found icon.

cheers!


Be Green Now or Never (BGNN)!

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

If you specify just ".lnk" extension, of course the icons will not be (nowhere to take). But if you specify the full path to the ".lnk" file, everything will be OK.

I specify a full path and the example are also using full path to the .ink icon. So i guess its not the issue.

Yashied. I have just ran the example on win 2008. The tree item were unable to be expand and some icons shown on the screen are black.

See the picture.

http://img145.imageshack.us/i/tvexpwin2008.jpg


Be Green Now or Never (BGNN)!

Share this post


Link to post
Share on other sites

You are using 16-bit color depth? OK, replace the _WinAPI_AddIconTransparency() function in WinAPIEx.au3 or wait until I update it.

Thanks.

Func _WinAPI_AddIconTransparency($hIcon, $iPercent = 50, $fDelete = 0)

    Local $tICONINFO, $tBIHDR, $tBITMAP, $W, $H, $Ret, $iByte, $tBits, $pBits, $hResult = 0
    Local $hBitmap[2]

    $tICONINFO = DllStructCreate($tagICONINFO)
    $Ret = DllCall('user32.dll', 'int', 'GetIconInfo', 'ptr', $hIcon, 'ptr', DllStructGetPtr($tICONINFO))
    If (@error) Or (Not $Ret[0]) Then
        Return SetError(1, 0, 0)
    EndIf
    For $i = 0 To 1
        $hBitmap[$i] = DllStructGetData($tICONINFO, $i + 4)
    Next
    Do
        $tBITMAP = DllStructCreate($tagBITMAP)
        If Not _WinAPI_GetObject($hBitmap[1], DllStructGetSize($tBITMAP), DllStructGetPtr($tBITMAP)) Then
            ExitLoop
        EndIf
        $W = DllStructGetData($tBITMAP, 'bmWidth')
        $H = DllStructGetData($tBITMAP, 'bmHeight')
        $iByte = $W * $H * 4
        $tBits = DllStructCreate('byte[' & $iByte & ']')
        $pBits = DllStructGetPtr($tBits)
        If _WinAPI_GetBitmapBits($hBitmap[1], $iByte, $pBits) <> $iByte Then
            ExitLoop
        EndIf
        For $i = 1 To $iByte Step 4
            DllStructSetData($tBits, 1, DllStructGetData($tBits, 1, $i + 3) * $iPercent / 100, $i + 3)
        Next
        _WinAPI_DeleteObject($hBitmap[1])
        $tBIHDR = DllStructCreate($tagBITMAPINFOHEADER)
        DllStructSetData($tBIHDR, 'biSize', DllStructGetSize($tBIHDR))
        DllStructSetData($tBIHDR, 'biWidth', $W)
        DllStructSetData($tBIHDR, 'biHeight', $H)
        DllStructSetData($tBIHDR, 'biPlanes', 1)
        DllStructSetData($tBIHDR, 'biBitCount', 32)
        DllStructSetData($tBIHDR, 'biCompression', $BI_RGB)
        $hBitmap[1] = _WinAPI_CreateDIBSection(0, $tBIHDR, $DIB_RGB_COLORS, $Ret)
        If @error Then
            ExitLoop
        EndIf
        If _WinAPI_SetBitmapBits($hBitmap[1], $iByte, $pBits) <> $iByte Then
            ExitLoop
        EndIf
        $hResult = _WinAPI_CreateIconIndirect($hBitmap[1], $hBitmap[0])
    Until 1
    For $i = 0 To 1
        If $hBitmap[$i] Then
            _WinAPI_DeleteObject($hBitmap[$i])
        EndIf
    Next
    If Not $hResult Then
        Return SetError(1, 0, 0)
    EndIf
    If $fDelete Then
        _WinAPI_DestroyIcon($hIcon)
    EndIf
    Return $hResult
EndFunc   ;==>_WinAPI_AddIconTransparency

Share this post


Link to post
Share on other sites

You are using 16-bit color depth? OK, replace the _WinAPI_AddIconTransparency() function in WinAPIEx.au3 or wait until I update it.

Thanks.

Func _WinAPI_AddIconTransparency($hIcon, $iPercent = 50, $fDelete = 0)

    Local $tICONINFO, $tBIHDR, $tBITMAP, $W, $H, $Ret, $iByte, $tBits, $pBits, $hResult = 0
    Local $hBitmap[2]

    $tICONINFO = DllStructCreate($tagICONINFO)
    $Ret = DllCall('user32.dll', 'int', 'GetIconInfo', 'ptr', $hIcon, 'ptr', DllStructGetPtr($tICONINFO))
    If (@error) Or (Not $Ret[0]) Then
        Return SetError(1, 0, 0)
    EndIf
    For $i = 0 To 1
        $hBitmap[$i] = DllStructGetData($tICONINFO, $i + 4)
    Next
    Do
        $tBITMAP = DllStructCreate($tagBITMAP)
        If Not _WinAPI_GetObject($hBitmap[1], DllStructGetSize($tBITMAP), DllStructGetPtr($tBITMAP)) Then
            ExitLoop
        EndIf
        $W = DllStructGetData($tBITMAP, 'bmWidth')
        $H = DllStructGetData($tBITMAP, 'bmHeight')
        $iByte = $W * $H * 4
        $tBits = DllStructCreate('byte[' & $iByte & ']')
        $pBits = DllStructGetPtr($tBits)
        If _WinAPI_GetBitmapBits($hBitmap[1], $iByte, $pBits) <> $iByte Then
            ExitLoop
        EndIf
        For $i = 1 To $iByte Step 4
            DllStructSetData($tBits, 1, DllStructGetData($tBits, 1, $i + 3) * $iPercent / 100, $i + 3)
        Next
        _WinAPI_DeleteObject($hBitmap[1])
        $tBIHDR = DllStructCreate($tagBITMAPINFOHEADER)
        DllStructSetData($tBIHDR, 'biSize', DllStructGetSize($tBIHDR))
        DllStructSetData($tBIHDR, 'biWidth', $W)
        DllStructSetData($tBIHDR, 'biHeight', $H)
        DllStructSetData($tBIHDR, 'biPlanes', 1)
        DllStructSetData($tBIHDR, 'biBitCount', 32)
        DllStructSetData($tBIHDR, 'biCompression', $BI_RGB)
        $hBitmap[1] = _WinAPI_CreateDIBSection(0, $tBIHDR, $DIB_RGB_COLORS, $Ret)
        If @error Then
            ExitLoop
        EndIf
        If _WinAPI_SetBitmapBits($hBitmap[1], $iByte, $pBits) <> $iByte Then
            ExitLoop
        EndIf
        $hResult = _WinAPI_CreateIconIndirect($hBitmap[1], $hBitmap[0])
    Until 1
    For $i = 0 To 1
        If $hBitmap[$i] Then
            _WinAPI_DeleteObject($hBitmap[$i])
        EndIf
    Next
    If Not $hResult Then
        Return SetError(1, 0, 0)
    EndIf
    If $fDelete Then
        _WinAPI_DestroyIcon($hIcon)
    EndIf
    Return $hResult
EndFunc   ;==>_WinAPI_AddIconTransparency

Cool! its working now with 16 and 32 BIT color.

At the beginning I thought its about the OS, now I am happy that I do not have to revert the code :) (just kidding).

Let me know If you need me to retest it on any combination that you would use it.

I have almost anything at work.

Edited by lsakizada

Be Green Now or Never (BGNN)!

Share this post


Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Synaps3
      This script will make it so you can press Alt + "+" in Windows Explorer to select all files with the current file extension. This is something that I wanted for a long time and it should be a feature in Windows, but it's not. The only way to get close is to use the search thing (but then it shows the results excluding everything else) or to group by that type, but I don't want it grouped.
      You can press Alt + Enter right after to open properties on those files or you can press delete to delete only files of that type.
      You need the "Automating Windows Explorer" pack here: https://www.autoitscript.com/forum/topic/162905-automating-windows-explorer/
       
      #include "Includes\AutomatingWindowsExplorer.au3" #include <Array.au3> Opt( "MustDeclareVars", 1 ) HotKeySet("!=", "SelectTypes") Func SelectTypes() ; Windows Explorer on XP, Vista, 7, 8 Local $hExplorer = WinGetHandle("[REGEXPCLASS:^(Cabinet|Explore)WClass$]") If Not $hExplorer Then MsgBox(0, "Explorer", "Could not find Windows Explorer.") Return EndIf $hExplorer = WinActive("[REGEXPCLASS:^(Cabinet|Explore)WClass$]") If Not $hExplorer Then MsgBox(0, "Explorer", "Windows Explorer is not in focus.") Return EndIf ; Get an IShellBrowser interface GetIShellBrowser($hExplorer) If Not IsObj($oIShellBrowser) Then MsgBox(0, "Explorer", "Could not get an IShellBrowser interface.") Return EndIf ; Get other interfaces GetShellInterfaces() ; Get selected files with full path ;GetFiles( $fSelected = False, $fFullPath = False, $fPidl = False, $iMax = 0 ) Local $aAllFiles = GetItems(False, False) Local $aFiles = GetItems(True, False) Local $sExt Local $i If UBound($aFiles) = 1 Then ;MsgBox(0, "Selected", $aFiles[0]) $sExt = StringRight($aFiles[0], StringLen($aFiles[0]) - StringInStr($aFiles[0], ".", 0, -1)) ;MsgBox(0, "Selected", $sExt) For $i = 0 To UBound($aAllFiles) - 1 If StringInStr($aAllFiles[$i], ".") > 0 Then If StringRight($aAllFiles[$i], StringLen($aAllFiles[$i]) - StringInStr($aAllFiles[$i], ".", 0, -1)) = $sExt Then SetSelectedItem($i) EndIf EndIf Next Else MsgBox($MB_ICONWARNING, "Error", "None or multiple items selected!") EndIf EndFunc While 1 GUIGetMsg() Wend  
    • By jcpetu
      Hi people, I'm trying to dynamically populate a TreeView based on a script from Water that I modified for my needs. but I can't figured it out how to make it work.
      Here what I have in case anyone can help me, thanks in advance:
      #include <array.au3> #include <GUIConstantsEx.au3> #include <GuiTreeView.au3> Local $aTV1[14][3] = [ _ ['1', 'Text 1', -1], _ ;-1 idicates it's an index item ['2', 'Text 2',-1], _ ['3', 'Text 3',-1], _ ['1-1', 'Text 1-1',0], _ ['1-2', 'Text 1-2',0], _ ['2-1', 'Text 2-1',0], _ ['2-2', 'Text 2-2',0], _ ['2-1-1', 'Text 2-1-1',0], _ ['2-1-2', 'Text 2-1-2',0], _ ['2-1-2-1', 'Text 2-1-2-1',0], _ ['2-1-2-1-1', 'Text 2-1-2-1-1',0], _ ['3-1', 'Text 3-1',0], _ ['3-1-1', 'Text 3-1-1',0], _ ['3-1-1-1', 'Text 3-1-1-1',0]] ;_ArrayDisplay($aTV1) Local $Gui = GUICreate('TreeView Example', 500, 600) Local $tv = GUICtrlCreateTreeView(10, 30, 450, 550) GUISetState() _pop_treeview($tv, $aTV1) While 1 Switch GUIGetMsg() Case $gui_event_close Exit EndSwitch WEnd Func _pop_treeview($hTV, $array) Local $TimeInitial = TimerInit(), $Hours, $Mins, $Secs, $item _ArraySort($array, 0, 0, 0, 0) ;------------------------- sort Ascending on column 0 ;_ArrayDisplay($array) $idxroot = _GUICtrlTreeView_Add($hTV, 0, "index") For $i = 0 To UBound($array) - 1 ConsoleWrite("$array[" & $i & "][" & 0 & "] = " & $array[$i][0] & @CRLF) If $array[$i][0] = '' Then ExitLoop ;--------------- Exit at first empty element $item = '' If $array[$i][2] = -1 Then ;------------------------ Add root element _GUICtrlTreeView_AddChild($hTV, $idxroot, $array[$i][1]) Else $item = StringLeft($array[$i][0], StringInStr($array[$i][0], "-", 1, -1) - 1) ConsoleWrite("$item = " & $item & @CRLF) $Found = _ArrayBinarySearch($array, $item, 0, 0, 0) ;search on column 0 Switch $Found Case 0 ;----------------------------------- Value wasn't found in array ConsoleWrite("Item NOT found @error= " & @error & @CRLF) Case Else ConsoleWrite("Item found " & @CRLF) _GUICtrlTreeView_AddChild($hTV, $Found, $array[$i][1]) EndSwitch EndIf Next _GUICtrlTreeView_Expand($hTV) EndFunc ;==>_pop_treeview  
    • By MesterPerfect
      good morning
      this is the first post here in the autoit forums
      i hope that you can help me in my problem
      i have a JSON encoded
      it a map of my forums
      where i want to make a treeview that have the same type of map
      e.g
      a system (as category)
      windows (as sub category)
      software (as an child item in the windows category)
      .....
      i don't know how to do that
      so, i know that i can do that using the json functions
      but i need your help about how we can do it as the type that i told you
      by the way i need to put the sub info for each item in an array that give me the ability to manage my items
      e.g
      can post thread
      can reply
      message cound ...
      you just give me a small example and i can continue.
      am sorry if this against the rules of the forum.
      but i realy searched a lot but i couldn't
      i hope some one give me the way.
      thank you very much in advance
       
      here is the link of json forum
      https://www.autoitscript.com/forum/topic/148114-a-non-strict-json-udf-jsmn/
      and here is my encoded json file
       
      { "tree_map": { "0": [ 1, 5, 6, 7 ], "1": [ 2 ], "2": [ 4 ], "5": [ 3 ], "6": [ 8 ], "8": [ 9, 10 ] }, "nodes": [ { "breadcrumbs": [], "description": "", "display_in_list": true, "display_order": 1, "node_id": 1, "node_name": null, "node_type_id": "Category", "parent_node_id": 0, "title": "Main category", "type_data": {} }, { "breadcrumbs": [ { "node_id": 1, "title": "Main category", "node_type_id": "Category" } ], "description": "", "display_in_list": true, "display_order": 1, "node_id": 2, "node_name": null, "node_type_id": "Forum", "parent_node_id": 1, "title": "Main forum", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [ { "node_id": 1, "title": "Main category", "node_type_id": "Category" }, { "node_id": 2, "title": "Main forum", "node_type_id": "Forum" } ], "description": "", "display_in_list": true, "display_order": 1, "node_id": 4, "node_name": null, "node_type_id": "Forum", "parent_node_id": 2, "title": "my forums1", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [], "description": "", "display_in_list": true, "display_order": 2, "node_id": 5, "node_name": null, "node_type_id": "Category", "parent_node_id": 0, "title": "Perfect", "type_data": {} }, { "breadcrumbs": [ { "node_id": 5, "title": "Perfect", "node_type_id": "Category" } ], "description": "", "display_in_list": true, "display_order": 2, "node_id": 3, "node_name": null, "node_type_id": "Forum", "parent_node_id": 5, "title": "ahmed", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [], "description": "", "display_in_list": true, "display_order": 3, "node_id": 6, "node_name": null, "node_type_id": "Forum", "parent_node_id": 0, "title": "autoit", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [ { "node_id": 6, "title": "autoit", "node_type_id": "Forum" } ], "description": "", "display_in_list": true, "display_order": 3, "node_id": 8, "node_name": null, "node_type_id": "Forum", "parent_node_id": 6, "title": "examples", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [ { "node_id": 6, "title": "autoit", "node_type_id": "Forum" }, { "node_id": 8, "title": "examples", "node_type_id": "Forum" } ], "description": "", "display_in_list": true, "display_order": 3, "node_id": 9, "node_name": null, "node_type_id": "Forum", "parent_node_id": 8, "title": "GUI", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [ { "node_id": 6, "title": "autoit", "node_type_id": "Forum" }, { "node_id": 8, "title": "examples", "node_type_id": "Forum" } ], "description": "", "display_in_list": true, "display_order": 31, "node_id": 10, "node_name": null, "node_type_id": "Forum", "parent_node_id": 8, "title": "windowEX", "type_data": { "allow_poll": true, "allow_posting": true, "can_create_thread": true, "can_upload_attachment": true, "discussion_count": 0, "last_post_date": 0, "last_post_id": 0, "last_post_username": "", "last_thread_id": 0, "last_thread_prefix_id": 0, "last_thread_title": "", "message_count": 0, "min_tags": 0, "require_prefix": false } }, { "breadcrumbs": [], "description": "", "display_in_list": true, "display_order": 4, "node_id": 7, "node_name": null, "node_type_id": "Category", "parent_node_id": 0, "title": "vbs", "type_data": {} } ] }  
    • By WoodGrain
      Hi All,
      Trying to open windows explorer to a WebDav location and it's not working quite how I want, on the computers it is setup as a "network location" (as opposed to a "mapped drive", and this unfortunately can't be changed), the "Data" WebDav folder sits directly under "This PC" if that's an easier way to get to it. any suggestions as to what I can correct to get the 2nd example to work?
      ; This works, but I'm trying to avoid this as users normally see the URL style in the 2nd example below $folderToOpen = "\\mycompany.sharepoint.com@SSL\DavWWWRoot\Data" Run("Explorer.exe " & $folderToOpen) ; This does not work, it tries to open the WebDav url in the default web browser $folderToOpen = "https://mycompany.sharepoint.com/Data" Run("Explorer.exe " & $folderToOpen) ShellExecute also opens it in the default browser.
      Saw _WinAPI_ShellOpenFolderAndSelectItems but couldn't get the 2nd example to work.
      If I manually open Windows Explorer and paste in https://mycompany.sharepoint.com/Data it loads the WebDav directory without issue.
      If I have to use the pathing from the first example it is fine, just trying to give users a familiar experience.
      Thanks!
    • By Burgs
      Hello,
        I am having great difficulty with something I would have thought to be fairly easy.  I have an array containing (military) organization strings, similar to this:
      42nd Battalion
       Company A
        1st Platoon
         1st Squad
         2nd Squad
         3rd Squad
        2nd Platoon
         ...1st, 2nd, 3rd Squad
        3rd Platoon
        ...1st, 2nd, 3rd Squad
       Company B
        ...etc...
      I also have an associated array that contains the 'hierarchy' information associated with each string..."0", "1","2", etc   ...therefore using example above the "0" would associate with "42nd Battalion", while "1" would be "Company A", "2" is "1st Platoon", etc.  Each sequential number is a 'child' of the preceding number.  Therefore the information above would appear in the array as "0", "1", "2", "3", "3", "3", "2", "3", "3", "3", "2", "3", "3", "3", "1", etc...
        My issue is that I'm having great difficulty creating a 'Treeview' control using this information.  Mainly due to the fact that entries can, and will...repeat (for example multiple entries for "Company A", "Company B", "1st Platoon", "1st Squad", etc, etc).  The following code is operative, however it does not create the treeview items as 'child' entries of one another...it simply lists each item as a separate entity.
      For $_populate = 0 to Ubound($_HIERARCHY) - 1 _GUICtrlTreeView_BeginUpdate($idTreeView) _GUICtrlTreeView_Add($idTreeView, $_HIERARCHY[$_populate], String($_STRUCTURES[$_populate])) _GUICtrlTreeView_EndUpdate($idTreeView) Next ;Next $_populate, cycle thru '$_HIERARCHY' array to build 'TREEVIEW' Controls As I mentioned earlier I thought I could manage this...however i'm pulling out quite a bit of my hair trying to get this working properly...any help would be appreciated.  I thank you in advance. 
       
×
×
  • Create New...