Jump to content

ChooseFileFolder - Interim Version 11 Mar 21


Melba23
 Share

Recommended Posts

  • Moderators

m00,

Thanks. I think I have it working now but I will look at your changes with interest.

Glad you got what you wanted as an interim - I will try and give you a more polished UDF in a while.

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

  • 3 months later...
  • Moderators

m00,

Sorry it took so long - a serious family illness and a new grandson got in the way!

Here is a new Beta of the UDF with the freezing _Embed bug fixed and a rather better-working ability to select both folders and files when required. There is a small change in both _Choose and _Embed functions - $iDisplay option 3 has been removed as the new logic means that is was identical to option 2. The new options work as follows:

Option    Display             Selectable          Action when folder double-clicked

0         Folders and files   Files only          Folder expands/contracts
1         Files only          Files only          N/A
2         Folders only        Folders only        Selects folder

+16       Folders and files   Folders and files   Selects folder
only when using option 0

There is also one small change for consistency: pressing the {ENTER} key when in single selection mode now selects the highlighted (highlit?) item in both _Choose and _Embed - it did not do so in _Choose before.

 

Please test it and let me know if you like it - and of course anyone else is free to test and comment as well.

M23

Edited by Melba23
Beta code removed

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

  • 1 month later...

Hi Melba,

I'm looking for a way to be able to update the "choose list" on the fly at my own trigger
That will act as a refresh to the list for any drive letters (newly available) or removed, (redrawn back to the GUI)
Without needing to close\restart the _CFF_Choose() function
I tried a few things without a desired outcome ..
Maybe you can devise something for this if not too busy

Thanks
Deye

Link to comment
Share on other sites

  • Moderators

Deye,

Quote

at my own trigger

What sort of "trigger" are you imagining? A new button on the dialog?

Quote

to update the "choose list" on the fly ... Without needing to close\restart the _CFF_Choose() function

Any solution would require the entire treeview to be rewritten - I cannot imagine that it would take much more time to close the existing dialog and simply call the function again. But if you answer the question above and give me a concrete use case I will take a look at what might be done.

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

Deye,

So basically a _CFF_Refresh function. I think I can see how it might be done, but you would almost certainly lose all previously selected items - would that be a problem?

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

Deye,

Have a play with this Beta and see what you think:

A quick example script - either press the "Return" button with Ctrl pressed or use the HotKey to refresh the drives available:

As I anticipated, you will lose any previously selected items, which I feel is reasonable as you could be refreshing the tree and now no longer have access to certain drives.

Let me know what you think - and comments from others are always welcome too.

M23

Edited by Melba23
Beta code removed

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

Hi Melba,

It works well, this only needs a small procedure to sustain the state of checks
just like what $g_aCFF_PreCheckRetain is for when reloading the function

3 hours ago, Melba23 said:

you will lose any previously selected items

Wasted 2 ours looking at the UDF
I tried a few things like ways to remove stale references to $sAddFile_List and Such but soon was getting some hunch that the TreeView may not Or can't be updated in such ways ..

.. back with my half baked thoughts .. will try again when i get a moment

Thanks again

Deye

Link to comment
Share on other sites

  • Moderators

Deye,

Quote

this only needs a small procedure to sustain the state of checks

Easy to say - especially from someone who is not going to have to code it! I take it that you would like to have any existing checkboxes re-checked when the new treeview is created?

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

Deye,

Sorry, I did realise that you had posted code above (which I have still not inspected) - here is my Beta which uses the __CFF_Refresh function called programmatically to toggle a "discard/retain existing selection during refresh" flag, while still allowing the same function to be called via a HotKey for the actual refresh (I must say I am quite pleased with that little trick!):

And a new example script showing the function in action - just check the console to see whether the items will be retained or discarded during the refresh:

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

#include "ChooseFileFolder_Deye.au3"

; Set HotKey (Ctrl-R) for refresh
HotKeySet("^r", "_CFF_Refresh")

_CFF_RegMsg()

$vRet = _CFF_Refresh(1)
ConsoleWrite("Retain: " & $vRet & @CRLF)

; Basic _Choose dialog
$sRet = _CFF_Choose ("Basic Test", 1, 1, -1, -1, "", "", 0, 50)
ConsoleWrite($sRet & " - " & @error & " - " & @extended & @CRLF)

$vRet = _CFF_Refresh(0)
ConsoleWrite("Retain: " & $vRet & @CRLF)

; Combo _Choose dialog
$sRet = _CFF_Choose ("Combo Test", 1, 1, -1, -1, "||c", "", 0, 50)
ConsoleWrite($sRet & " - " & @error & " - " & @extended & @CRLF)

$vRet = _CFF_Refresh(1)
ConsoleWrite("Retain: " & $vRet & @CRLF)

; Checkbox _Choose dialog
$sRet = _CFF_Choose ("Checkbox Test", 1, 1, -1, -1, "", "", 0, -1)
ConsoleWrite($sRet & " - " & @error & " - " & @extended & @CRLF)

$vRet = _CFF_Refresh(0)
ConsoleWrite("Retain: " & $vRet & @CRLF)

; Create GUI for _Embed test
$hGUI = GUICreate("Embed Test", 500, 500)
$cTreeView = GUICtrlCreateTreeView(10, 10, 200, 200)
$cReturn = GUICtrlCreateButton("Return", 400, 10, 80, 30)
$cList = GUICtrlCreateList("", 10, 300, 200, 150)
$cRefresh = GUICtrlCreateDummy()
GUISetState()

; _Embed
$sRet = _CFF_Embed ($cTreeView, "", "*", 0, $cReturn, $cList, $cRefresh)
ConsoleWrite($sRet & " - " & @error & " - " & @extended & @CRLF)

$vRet = _CFF_Refresh(1)
ConsoleWrite("Retain: " & $vRet & @CRLF)

$sRet = _CFF_Embed ($cTreeView, "", "*", 0, $cReturn, $cList, $cRefresh)
ConsoleWrite($sRet & " - " & @error & " - " & @extended & @CRLF)

Let me know what you think. And please take note of this warning in the __CFF_Refresh header:

; NOTE: When using Ctrl-Return the CTRL key MUST be kept pressed until the refresh splash screen appears
;       This is particularly true when treeview checkboxes are enabled

I found that the added code was slowing the UDF when new branches were being filled and if I actioned a Ctrl-"Return" refresh immediately there was a possibility of the button event happening after a short delay, with the result that the Ctrl key was no longer pressed at that point - and so the UDF assumed that I wanted to "Return" and promptly did so!

M23

Edited by Melba23
Beta code removed

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

Melba,

I didn't yet get to try your new mod but I see its now about 130 lines or so, longer ..
I'm only using _CFF_Choose, don't know anything about what is needed for the other modes

I managed already to solve the refreshing plus save the tick's with what I have last posted, Took advantage of the already existing case functions in the loop without the need to add any extra code

with this one ChooseFileFolder_Deye_Mod.au3, I even added the expanding back to the last selected item in the TreeView .

Link to comment
Share on other sites

Melba,

The last mode you had posted doesn't seem to react on doing a refresh
Neither show any new drive after plugging a pen drive when doing a refresh right after

I came out with this so far
A new drive should show up when plugging in a pen drive or deleted when unplugged,  pointing the refresh to this function

Func _CFF_ReCheck_Drives($cTV, ByRef $sDrives, ByRef $aAll_Drives)
    Local $hTV, $cItem, $hItem, $aAll_Drives_ReCheck = DriveGetDrive("ALL")

    Local $bNative_TV = True
    If IsHWnd($cTV) Then
        $bNative_TV = False
        $hTV = $cTV
    Else
        $hTV = GUICtrlGetHandle($cTV)
    EndIf

    ; Removing drives that are no longer connected
    For $i = 1 To $aAll_Drives[0]
        _ArraySearch($aAll_Drives_ReCheck, $aAll_Drives[$i])
        If @error = 6 Then _GUICtrlTreeView_Delete($hTV, _GUICtrlTreeView_FindItem($hTV, $aAll_Drives[$i], "", 0))
    Next

    ; inserting new drives that are not currently listed in the treeview
    For $i = 1 To $aAll_Drives_ReCheck[0]
        If _GUICtrlTreeView_FindItem($hTV, $aAll_Drives_ReCheck[$i], "", 0) Then
            $hItem = _GUICtrlTreeView_FindItem($hTV, $aAll_Drives_ReCheck[$i], "", 0)
            ContinueLoop
        EndIf
        _GUICtrlTreeView_InsertItem($hTV, StringUpper($aAll_Drives_ReCheck[$i]), 0, $hItem)
        _GUICtrlTreeView_SetChildren($hTV, $hItem, 1)
    Next

    $aAll_Drives = $aAll_Drives_ReCheck
    $sDrives = $aAll_Drives
EndFunc

Will stop by later to see if anything new arises

Thanks

Deye

Edited by Deye
changed code
Link to comment
Share on other sites

Hi Melba,

No matter what I have tried It was just impossible using _GUICtrlTreeView_InsertItem  (@ adding\keeping the hierarchy of the letters in check)

Any how, by amending in a few lines as shown in this part Its now resolved to add drives (as last on the parent root ) .. without need for redrawing @ calling this function alone on refresh

Spoiler
Func _CFF_Fill_Drives($cTV, ByRef $aAll_Drives, $sDefDrive, $sDefFolder, $bDeepest, $bNoFolderCheck)

    Local $hTV, $cItem

    ; Check if native or UDF TV
    Local $bNative_TV = True
    If IsHWnd($cTV) Then
        $bNative_TV = False
        $hTV = $cTV
    Else
        $hTV = GUICtrlGetHandle($cTV)
    EndIf

    Local $sDrive, $cDefDriveItem = 0, $hItem,$aAll_Drives_Tmp = DriveGetDrive("ALL")

    For $i = 1 To $aAll_Drives[0]
        _ArraySearch($aAll_Drives_Tmp, $aAll_Drives[$i])
        If @error = 6 Then
            _GUICtrlTreeView_Delete($hTV, _GUICtrlTreeView_FindItem($hTV, $aAll_Drives[$i], "", 0))
        EndIf
    Next
    $aAll_Drives = $aAll_Drives_Tmp

    _GUICtrlTreeView_BeginUpdate($hTV)
    For $i = 1 To $aAll_Drives[0]
        ; Extract drive
        $sDrive = $aAll_Drives[$i]
        ; Only display ready drives
        If DriveStatus($sDrive & '\') == "READY" Then
            If _GUICtrlTreeView_FindItem($hTV, $aAll_Drives[$i], "", 0) Then ContinueLoop

 

Thanks again

Deye

Link to comment
Share on other sites

  • 1 month later...

Hi Melba,

i'm new to AutoIt but i've to say, I really like it more and more. Trying it out, I came across your script "ChooseFileFolder".

I wonder if it's possible to adjust your script without too much effort so that it lists the icons of the folders and files as well (inbetween checkbox and filename).

A little example of a TreeView with Icons by a script from Yashied:

Thank you for your great scripts :)
Slevin

Link to comment
Share on other sites

  • Moderators

SlevinKT,

Welcome to the AutoIt forums. Glad you find my code useful.

But I am afraid I am not going to implement icons in this UDF as I believe it would seriously slow the main expansion algorithm. Sorry.

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

Hi Melba,

On a side note: maybe icons could be optional (for later .. ) if first _CFF_AutoExpand could go a little faster 

This copy works for me much faster, tested with demanded re-expands to deep $sSelectedPath 's on redraws without delays ..
 

Func _CFF_AutoExpand($hTreeView, $iDisplay, $sMask, $bShow_Ext, $iHide_HS, $aNetwork_Drives, $sDefFolder, $bDefFolder_Open, $iRedraw_Count, $bDeepest, $bNoFolderCheck, $bCombo = False, $bNative_TV = False)

    Local $aDefFolder_Split, $hDefFolder_Item, $vParent_Item, $sDefExpand_Path = "", $sItem

    ; Set flag to prevent expansion dummy firing
    $g_bCFF_AutoExpand = True

    ; Split path into elements
    $aDefFolder_Split = StringSplit($sDefFolder, "\")

    ; Looking for the first element
    $sDefExpand_Path = $aDefFolder_Split[1] & "\"

    ; Get initial handle to start process
    $hDefFolder_Item = _GUICtrlTreeView_FindItem($hTreeView, $aDefFolder_Split[1], "", 0)

    For $i = 1 To $aDefFolder_Split[0]
        If $i > 1 Then
            ; Set required path
            $sDefExpand_Path &= $aDefFolder_Split[$i] & "\"
            While $hDefFolder_Item <> 0x00000000
                If _GUICtrlTreeView_GetText($hTreeView, $hDefFolder_Item) == $aDefFolder_Split[$i] Then ExitLoop
                $hDefFolder_Item = _GUICtrlTreeView_GetNextSibling($hTreeView, $hDefFolder_Item)
            WEnd
        EndIf

        _GUICtrlTreeView_SelectItem($hTreeView, $hDefFolder_Item)
        $vParent_Item = GUICtrlRead($hTreeView)

        If $i = $aDefFolder_Split[0] - 1 And Not ($aDefFolder_Split[$aDefFolder_Split[0]]) Then
            If (Not $bDefFolder_Open) Then
                ExitLoop
            EndIf
        EndIf

        ; Fill branch
        _CFF_Fill_Branch($hTreeView, $vParent_Item, $sDefExpand_Path, $iDisplay, $sMask, $bShow_Ext, $iHide_HS, $aNetwork_Drives, $bDeepest, $bNoFolderCheck)
        ; Check for content - final folder may be empty
        If _GUICtrlTreeView_GetChildCount($hTreeView, $hDefFolder_Item) > 0 Then
            ; Delete existing first blank child
            _GUICtrlTreeView_Delete($hTreeView, _GUICtrlTreeView_GetFirstChild($hTreeView, $hDefFolder_Item))
            ; Get new first item
            $hDefFolder_Item = _GUICtrlTreeView_GetFirstChild($hTreeView, $hDefFolder_Item)
        EndIf
    Next

    ; Clear flag to re-enable expand dummy
    $g_bCFF_AutoExpand = False

EndFunc   ;==>_CFF_AutoExpand

 

Link to comment
Share on other sites

  • 3 months later...

@Melba23

Hello, nice work on this udf.

Everything is working fine, if not compiled. 

If compiled i only get the c drive as ready not my other 3 drives. 

If i run the stripped script everything is fine. 

I probably do something wrong i guess, can you help me?

https://drive.google.com/open?id=1X4lQh1mpWKxPbxRI7_VvrylJ8JtfQrfq

Edit: It list all drives, but all folders are under C and the other drives are empty

Edited by xtcislove
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...