Jump to content

TVExplorer UDF


Yashied
 Share

Recommended Posts

LAST VERSION - 1.3

28-Jan-15

Unlike >this, here is a fully ready UDF library. The library allows you to create TreeView (TV) Explorer controls that displays a tree of files and folders for the specified root folder with the specified parameters. TV Explorer controls is self-contained GUI controls that do not require you any further doing. Note that TVExplorer UDF requires >WinAPIEx UDF version 3.3 or later.

To create TV Explorer control, just call the _GUICtrlTVExplorer_Create() function. And that's it. If you want to be notified about events such as the changing selection, the beginning and ending of the updating TV Explorer control, mounting and unmounting removeable drives, etc., you must specify a user function to retrieve these notifications, like WM-functions. How it works is shown in the following example. This library can work in "Loop" and "OnEvent" GUI modes. If the "GUIOnEventMode" option is set to 0, you should use _GUICtrlTVExplorer_GetMsg() instead of native GUIGetMsg() function, otherwise, the TV Explorer controls will not work. In using, these two functions are completely equivalent. A more detailed description of all functions you'll find inside the library.

TVExplorer.png

Available functions

_GUICtrlTVExplorer_AttachFolder

_GUICtrlTVExplorer_Create

_GUICtrlTVExplorer_Destroy

_GUICtrlTVExplorer_DestroyAll

_GUICtrlTVExplorer_Expand

_GUICtrlTVExplorer_GetMsg

_GUICtrlTVExplorer_GetPathFromItem

_GUICtrlTVExplorer_GetRootPath

_GUICtrlTVExplorer_GetSelected

_GUICtrlTVExplorer_SetExplorerStyle

_GUICtrlTVExplorer_UpdateIcon

TVExplorer UDF Library v1.2

Previous downloads: 2266

TVExplorer.zip

Example 1

#Include <APIConstants.au3>
#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

Example 2 (OnEvent mode)

#Include <APIConstants.au3>
#Include <GUIConstantsEx.au3>
#Include <GUITreeView.au3>
#Include <TVExplorer.au3>
#Include <TreeViewConstants.au3>
#Include <WindowsConstants.au3>
#Include <WinAPIEx.au3>

Opt('MustDeclareVars', 1)
Opt('GUIOnEventMode', 1)

Global $hForm, $hTV[3], $Input[3], $hFocus = 0, $Dummy, $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)
GUISetOnEvent($GUI_EVENT_CLOSE, '_GUIEvent')
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()
GUICtrlSetOnEvent(-1, '_GUIEvent')
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
    Sleep(1000)
WEnd

Func _GUIEvent()

    Local $Path

    Switch @GUI_CtrlId
        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
EndFunc   ;==>_GUIEvent

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
Edited by Yashied
Link to comment
Share on other sites

Hi Yashied (Jack),

nice work as usual. Can I use it also for adding other data to treeview?

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Wow - very impressive :)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Link to comment
Share on other sites

  • Moderators

Yashied,

I hate you - I have just spent a week writing a UDF which does this sort of thing with a native treeview and you produce this! :idiot:

Well up to your usual standard. :)

As I see you are using FileFindFirst/NextFile I imagine it would not be too hard to limit the displayed tree to folders only or to filter the files displayed in the same manner as manner as my RecFileListToArray UDF - or am I mistaken? ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

Yashied,

Any objections if I play with it to see what I can produce along those lines? :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

Yashied,

Спасибо, мой друг. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

Yashied,

That was far too easy - I am sure you knew how to do it all along! ;)

All that is needed is to utilise the $sTemplate parameter of the _GUICtrlTVExplorer_Create function.

First you need to set the default value of the parameter to something that you know cannot be matched - I suggest using ":.:" as ":" is a forbidden character within file names.

Func _GUICtrlTVExplorer_Create($sRoot, $iX, $iY, $iWidth = -1, $iHeight = -1, $iStyle = -1, $iExStyle = 0, $iFlags = -1, $sFunc = '', $sTemplate = ':.:')

Then passing no value in the parameter produces a tree showing only folders, while passing a mask will display the files which match the mask - multiple masks are separated by ";".

These lines taken from the example script have been modifed to show how you might use this:

; Display only .au3 and .ico files in the AutoIt installation folders:
$hTV[0] = _GUICtrlTVExplorer_Create(@ProgramFilesDir & "\AutoIt3", 20, 48, 320, 310, -1, $WS_EX_CLIENTEDGE, -1, '_TVEvent', '*.au3;*.ico') ; set template to *.au3 and *.ico

; Display only folders - no files at all
$hTV[1] = _GUICtrlTVExplorer_Create(@UserProfileDir, 360, 48, 320, 310, -1, $WS_EX_CLIENTEDGE, -1, '_TVEvent') ; no template parameter passed so default used = no matches

; Display all files
$hTV[2] = _GUICtrlTVExplorer_Create('', 20, 406, 660, 310, -1, $WS_EX_CLIENTEDGE, -1, '_TVEvent', "*.*") ; template matches all files

I hope this minor addition to Yashied's excellent UDF proves useful to others. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

To get the maximum enumerating speed is better to use only $TV_FLAG_DIRTREE or other combination of $TV_FLAG_* flags, excluding $TV_FLAG_SHOWFILES. $sTemplate parameter apply only to files.

; Display only .au3 and .ico files in the AutoIt installation folders:
$hTV[0] = _GUICtrlTVExplorer_Create(@ProgramFilesDir & "\AutoIt3", 20, 48, 320, 310, -1, $WS_EX_CLIENTEDGE, -1, '_TVEvent', '*.au3;*.ico') ; set template to *.au3 and *.ico

; Display only folders - no files at all
$hTV[1] = _GUICtrlTVExplorer_Create(@UserProfileDir, 360, 48, 320, 310, -1, $WS_EX_CLIENTEDGE, $TV_FLAG_DIRTREE, '_TVEvent') ; no template parameter passed so default used = no matches

; Display all files
$hTV[2] = _GUICtrlTVExplorer_Create('', 20, 406, 660, 310, -1, $WS_EX_CLIENTEDGE, -1, '_TVEvent') ; template matches all files
Edited by Yashied
Link to comment
Share on other sites

  • 2 weeks later...

Yashied,

I have a problem to implement the mode into my code application.

The handlers does not work for me.

I found in the UDF this info:

; IMPORTANT: If you register the following window messages in your code, you should call handlers from this library until
; you return from your handlers, otherwise, the TreeView Explorer will not work properly! For example:
;
; Func MY_WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
;     Local $Result = TV_WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
;     If $Result <> $GUI_RUNDEFMSG Then
;         Return $Result
;     EndIf
;     ...
; EndFunc

So I created the TVExplorer with the following code.

Am I doing OK?

I am prety much lost here..

_GUICtrlTVExplorer_Create(@ProgramFilesDir, 188, 160, 328, 140, -1, $WS_EX_CLIENTEDGE, -1, 'WM_NOTIFY')
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

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_2[11]
            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
        Case $Control_3[12]
            Consolewrite("$iCode=" & $iCode &  ", $TV_NOTIFY_SELCHANGED=" & $TV_NOTIFY_SELCHANGED & @CRLF)
            Select
                Case $iCode = $TV_NOTIFY_BEGINUPDATE
                    GUISetCursor(1, 1)
                Case $iCode = $TV_NOTIFY_ENDUPDATE
                    GUISetCursor(2)
                Case $iCode = $TV_NOTIFY_SELCHANGED
                    ;For $i = 0 To 2
                    ;If $Control_3[12] = $hWnd Then
                    _TVSetPath($Control_3[11], $iWparam)
                    ;ExitLoop
                    ;EndIf
                    ; Next
                Case $iCode = $TV_NOTIFY_DBLCLK
                    shellexecute(_GUICtrlTVExplorer_GetSelected($Control_3[12]))
                    ; Nothing
                Case $iCode = $TV_NOTIFY_RCLICK
                    ; Nothing
                Case $iCode = $TV_NOTIFY_DELETINGITEM
                    ; Nothing
                Case $iCode = $TV_NOTIFY_DISKMOUNTED
                    ; Nothing
                Case $iCode = $TV_NOTIFY_DISKUNMOUNTED

            EndSelect
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY
Edited by lsakizada

Be Green Now or Never (BGNN)!

Link to comment
Share on other sites

_GUICtrlTVExplorer_Create(@ProgramFilesDir, 188, 160, 328, 140, -1, $WS_EX_CLIENTEDGE, -1, 'WM_NOTIFY')

WM_NOTIFY that you specify in this function is not a Windows Message function. This is a user-defined function. Look closely at the examples. What do you exactly want to do?
Link to comment
Share on other sites

I just want to use the UDF into my code and make the tree browsable.

I saw the example and I understood it.

Not worked for me once I set it simmilar to the example using the _TVEvent function.

The TVEvent was not called when I tried to expand the tree with the mouse.

So I went to the WM_NOTIFY function and added the handlers there.

What did you mean in yours important note?

Be Green Now or Never (BGNN)!

Link to comment
Share on other sites

The TVEvent was not called when I tried to expand the tree with the mouse.

When you expand a folder, TVExplorer sends two messages to the _TV_Event() function: $TV_NOTIFY_BEGINUPDATE and $TV_NOTIFY_ENDUPDATE. It works for you? Edited by Yashied
Link to comment
Share on other sites

When you expand a folder, TVExplorer sends two messages to the _TV_Event() function: $TV_NOTIFY_BEGINUPDATE and $TV_NOTIFY_ENDUPDATE. It works for you?

No , The all function was not called.

I have put debug mesage.

Func _TVEvent($hWnd, $iMsg, $sPath, $hItem)
    
    Consolewrite("$iMsg=" & $iMsg &  @CRLF)
    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 $Control_3[12] = $hWnd Then
                _TVSetPath($Control_3[11], $sPath)
                ;ExitLoop
            EndIf
            ; Next
        Case $TV_NOTIFY_DBLCLK
            ;shellexecute(_GUICtrlTVExplorer_GetSelected($hTV[0]))
            ; Nothing
        Case $TV_NOTIFY_RCLICK
            ; Nothing
        Case $TV_NOTIFY_DELETINGITEM
            ; Nothing
        Case $TV_NOTIFY_DISKMOUNTED
            ; Nothing
        Case $TV_NOTIFY_DISKUNMOUNTED
            ; Nothing
    EndSwitch
EndFunc   ;==>_TVEvent
Edited by lsakizada

Be Green Now or Never (BGNN)!

Link to comment
Share on other sites

Please post a working example.

Hi, Yashied, I simmulated a simple code which somehow close to my application.

Hope I am not missing anything important to run the code..i was hurry

1) Set the TVExplore udf under include folder (WITH WINAPIEX UDF's two files)

2) The TVExplore GUI is in the second chiled application (Click next once after the load)

;; 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]
            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)!

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

×
×
  • Create New...