michaelslamet Posted June 16, 2013 Share Posted June 16, 2013 Hi Melba, When I try the example code, it works perfectly. However when I try to combine the code into mine, the tree doesn't displayed correctly. I suspect it's because of this: $sRet = _CFF_RegMsg() If Not $sRet Then MsgBox(16, "Failure!", "Handler not registered") Exit EndIf On my code, there is already a function to handle WM Notify: GUIRegisterMsg($WM_DROPFILES, 'WM_DROPFILES_FUNC') GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") ;This intercepts the Notification windows sends your GUI when you right click the listview (and many others) amd sends it to the "WM_NOTIFY" function. expandcollapse popupFunc WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo If Not IsHWnd($List) Then $hWndListView = GUICtrlGetHandle($List) ;$ilParam is a pointer. This reads what's at that adress. (not sure why the name suggests its an int) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom ;Check what control triggered the msg Case $hWndListView ;If it was the listview... Switch $iCode ;Check what action triggered the msg Case $NM_RCLICK ;If it was a right click... $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) ;get the information about the item clicked. $sItemText = _GUICtrlListView_GetItemText($hWndListView, DllStructGetData($tInfo, "Index"), DllStructGetData($tInfo, "SubItem")) ;store the item text in a global variable in case the Delete option is clicked. ;You could also just store the Index and SubItem values, the entire $tInfo struct, or whatever works best for you. ;Uncomment the next part to get more information about your click. ;~ _DebugPrint("$NM_RCLICK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ ;~ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ ;~ "-->Code:" & @TAB & $iCode & @LF & _ ;~ "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @LF & _ ;~ "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF & _ ;~ "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @LF & _ ;~ "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @LF & _ ;~ "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @LF & _ ;~ "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @LF & _ ;~ "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @LF & _ ;~ "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @LF & _ ;~ "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags")) EndSwitch EndSwitch ;Returning this allows the GUI to handle the messages in the usual way once you're done. Returning anything else will block default behavior. (giving you a largely unresponsive GUI) Return $GUI_RUNDEFMSG EndFunc In this situation, how to make it work? Link to comment Share on other sites More sharing options...
michaelslamet Posted June 16, 2013 Share Posted June 16, 2013 *Sigh*, what an idiot In ChooseFileFolder.au3 its clearly said: "If a WM_NOTIFY handler already registered, then call this function from within that handler" I'm sorry Melba for disturb Now It's all clear Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 18, 2013 Author Moderators Share Posted June 18, 2013 (edited) Good evening, I have been thinking about reintroducing the sliding separator between the treeview and the list that was present in the first few releases. I removed it because some people found that my GUIFrame UDF (which was required to have this functionality) did not work on their machines and I wanted the UDF to be universally usable. But I think I have have come up with a way to have frames for those who want to (and can) use them. If you ask for frames, this Beta version looks for the GUIFrame include and creates them if it is present. If the include is not present, then the Beta version defaults to the "standard" fixed sizes. The trick is to use strings to Call the GUIFrame functions and only set the function name to the required UDF function if the GUIFrame include is present - that way you do not get a syntax error if the function is not found. However, this does pose a problem if you use Obfuscator, as the required functions could well be stripped unless ignored as shown in the example. I see 3 possible ways forward (although I am happy to hear about any others that might exist): - 1. I forget about the sliding separator because no-one else is too bothered about having it. - 2. I release a new version based on this Beta which will permit frames, but which could cause Obfuscator to hiccup. - 3. I release this version together with the current release so that people can choose which version to use. So over to you - what do people who use this UDF think? M23 Edit: Best I add the files! CFF_Frame.zip Edited May 10, 2020 by Melba23 Beta code removed 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Noviceatthis Posted June 27, 2013 Share Posted June 27, 2013 Hello all _CFF_Choose("Choose Autoit File", 500, 500, -1, -1, @DesktopDir & "\", "*.au3", 1) so once the file has been selected, how does one open it?? many thanks Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 27, 2013 Author Moderators Share Posted June 27, 2013 Noviceatthis,I imagine ShellExecute would be the way to go - that way you either open the au3 file for editing or run it depending on how you set up your system when you installed AutoIt. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Noviceatthis Posted June 27, 2013 Share Posted June 27, 2013 Got it, thanks Link to comment Share on other sites More sharing options...
jmon Posted July 2, 2013 Share Posted July 2, 2013 Very nice and very fast! I think it's missing something compared to the fileopendialog, which is the ability to start with a file already selected or to start in a folder. It would be very nice to have this feature! [center]www.jmontserrat.comFile Sequence UDF - _StringExtractPaths - _StringTrimPattern - GuiCtrlSetOnTop - CalendarUDF[/center] Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 2, 2013 Author Moderators Share Posted July 2, 2013 jmon,Thanks for the compliments. Please note that you can indeed start in any folder - just add the full path as the $sRoot parameter and the tree begins at that point. I will look into how the UDF might highlight a pre-selected file as it opens - no promises though! M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 2, 2013 Author Moderators Share Posted July 2, 2013 jmon,Give this Beta code a run and see if it works for you. All you need do is specify the pre-selected file in the $sRoot parameter like this:#include "ChooseFileFolder_Mod.au3" Local $sRoot = StringRegExpReplace(@AutoItExe, "(^.*\\)(.*)", "\1") & "Au3Info.exe" ; This is a file and not a folder $aList = _CFF_Choose("Pre-Selected File", 300, 500, Default, Default, $sRoot)And here is the Beta UDF to run with it: Feedback welcome from other readers too, of course. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Tankbuster Posted August 1, 2013 Share Posted August 1, 2013 Hello Melba, your UDF is growing nicely . Well done (again) One request or idea. When I run your UDF on a remote drive. Sometimes on Remote drives, and because of diskspace and network for a "long" time it looks like the app is stoppd. It would be nice if a optional text is next to the "tree symbol" displayed. FOLDER L better FOLDER L <reading - pls wait> This happens when very large remote drives are read. Example a NAS drive. (on first access maybe the NAS needs some time to spin up, read....and so on. With the msg a user could see that something is working and does not try to kill the app... Maybe a old fashioned DOS spinning "" ? Or dots ? Does this make sense to you? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 2, 2013 Author Moderators Share Posted August 2, 2013 (edited) Tankbuster,Back when the UDF was so slow I did have a "Please wait" label appear - I got rid of it because the new code speeded the UDF up so much that I felt it was no longer necessary. I can easily put something like that back in the code. But is there anything in the path used to run the UDF on these remote drives which could act as a trigger so that the label is not displayed when running on local drives? Or perhaps it could appear if there was a delay over a certain period - how long a delay are you talking about here? M23 Edited August 2, 2013 by Melba23 Fixed BB tags 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Tankbuster Posted August 2, 2013 Share Posted August 2, 2013 (edited) I just did a test on the actual env. And it is about 4-6 seconds. So if you old and slow like myself, it would be still fast enough, but today's user a used to "action", feedback.... Does DrivegetDrive (network) maybe does the trick you are talking about as a trigger? And don't dare to ask. You got a ADD button but for DELETE I need to press CTRL, right? Is a "+" and a "-" button with tooltip a better option? Just to get similar usability on add and remove? Otherwise I need to explain before calling the UDF how a file is removed..... Edited August 2, 2013 by Tankbuster Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 2, 2013 Author Moderators Share Posted August 2, 2013 Tankbuster,Excellent idea about DriveGetDrive("NETWORK") - that should do the trick. As to adding a "DELETE" button - good call. I will look at that at the same time. Are you using Vista+? Because I could then use a split button to do both. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 2, 2013 Author Moderators Share Posted August 2, 2013 Tankbuster,I have added a "Delete" button for the CFF_Choose dialog - but kept the "Delete on Ctrl-DoubleClick" for CFF_Embed and deleting via the mouse. I have also added a "Just bloody wait" dialog * if the UDF is accessing a network drive - it is shown until the treeview is filled. So that should cover both your requests. Try this Beta code and see what you think:expandcollapse popup#include-once ; #INDEX# ============================================================================================================ ; Title .........: ChooseFileFolder ; AutoIt Version : 3.3 + ; Language ......: English ; Description ...: Allows selection of single or multiple files and/or folders from within a specified path ; Remarks .......: - If the script already has a WM_NOTIFY handler then call the _CFF_WM_NOTIFY_Handler function ; from within it ; - Requires another Melba23 UDF: RecFileListToArray.au3 ; Author ........: Melba23 ; Modified ......; Thanks to guinness for help with the #*@#*%# Struct !!!! ; ==================================================================================================================== ;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 ; #INCLUDES# ========================================================================================================= #include <GuiTreeView.au3> #include "RecFileListToArray.au3" ; #GLOBAL VARIABLES# ================================================================================================= Global $cCFF_Expand_Dummy, $cCFF_DblClk_Dummy ; #CURRENT# ========================================================================================================== ; _CFF_Choose: Creates a dialog to chose single or multiple files or folders within a specified path ; _CFF_Embed: Creates the folder tree within an existing treeview and optional list ; _CFF_RegMsg: Registers WM_NOTIFY to action doubleclick and item expansion on TreeView ; _CFF_WM_NOTIFY_Handler: Windows message handler for WM_NOTIFY - reacts to doubleclick and item expansion on TreeView ; ==================================================================================================================== ; #INTERNAL_USE_ONLY#================================================================================================= ; _CFF_Combo_Fill: Creates and fills a combo to allow drive selection ; _CFF_Fill_Branch: Fills a TreeView branch with folders and files on expansion ; _CFF_Check_Display: Checks for valid Display parameter ; _CFF_Check_Selection: Checks selection is valid ; _CFF_List_Add: Adds item to return list ; ==================================================================================================================== ; #FUNCTION# ========================================================================================================= ; Name...........: _CFF_Choose ; Description ...: Creates a dialog to chose single or multiple files or folders within a specified path ; Syntax.........: _CFF_Choose ($sTitle, $iW, $iH, $iX, $iY, [$sRoot = "", [$s_Mask = "", [$iDisplay = 0, [$iMultiple = True, [$hParent = 0]]]]]) ; Parameters ....: $sTitle - Title of dialog ; $iW, $iH - Width, Height parameters for dialog (Minimum 300 x 130/190 for single/multi selections) ; $iX, $iY - Left, Top parameters for dialog (Default = centred) ; $sRoot - Valid path = Tree to display ; To show combo for drive selection: ; "" (default) = All ready drives shown ; List of drive letters (e.g. "cde") = Limit combo content to these drives if ready ; Add "|drive letter" (e.g. "cde|d" or "|d") to display drive tree on opening ; $sMask - Filter for result. Multiple filters must be separated by ";" ; Use "|" to separate 3 possible sets of filters: "Include|Exclude|Exclude_Folders" ; Include = Files/Folders to include (default = "*" [all]) ; Exclude = Files/Folders to exclude (default = "" [none]) ; Exclude_Folders = only used if the basic $iDisplay = 0 to exclude defined folders (default = "" [none]) ; $iDisplay - Determine what is displayed in the tree ; 0 - Entire folder tree and all matching files within folders - only files can be selected ; 1 - All matching files within the specified folder - subfolders are not displayed ; 2 - Entire folder tree only - no files. Doubleclicks will expand, not select, item ; 3 - As 2 but doubleclicks will select item if it has no children ; + 4 - Do not display Hidden files/folders ; + 8 - Do not display System files/folders ; + 16 - Both files and folders can be selected - only valid if $iDisplay set to 0 ; + 32 - Allow duplicate selections ; + 64 - Hide file extensions (only valid if file mask specifies a single extension) ; $iMultiple - 0 or non-numeric = Only 1 selection (default) ; 10-50 = Multiple selections added to list. List size 10-50% of dialog ; Other numeric = Multiple selections added to list. List size set to 20% of dialog ; $hParent - Handle of GUI calling the dialog, (default = 0 - no parent GUI) ; Requirement(s).: v3.3 + ; Return values .: Success: String containing selected items - multiple items delimited by "|" ; Failure: Returns "" and sets @error as follows: ; 1 = Invalid $sRoot parameter (path does not exist or invalid drive list) ; 2 = Invalid $iDisplay parameter ; 3 = Invalid $hParent parameter ; 4 = Dialog creation failure ; 5 = Cancel button or GUI [X] pressed ; Author ........: Melba23 ; Modified ......: ; Remarks .......: For multiple selection: Press "Add" or doubleclick to add item to list ; Press "Delete" to delete item from list ; Press "Return" when selection ended ; Example........: Yes ;===================================================================================================================== Func _CFF_Choose($sTitle, $iW, $iH, $iX = -1, $iY = -1, $sRoot = "", $sMask = "*", $iDisplay = 0, $iMultiple = 0, $hParent = 0) Local $fShow_Ext = True, $iHide_HS = 0, $fBoth_Selectable = False, $fDuplicates_Allowed = False, $sDrives = "", $sDefDrive = "" ; Check position If $iX = Default Then $iX = -1 EndIf If $iY = Default Then $iY = -1 EndIf ; Check path Switch $sRoot Case "", Default $sRoot = "" Case Else ; If a path If FileExists($sRoot) Then ; Add trailing \ if needed If StringRight($sRoot, 1) <> "\" Then $sRoot &= "\" EndIf Else ; Check for valid drive list (cde, cde|c, |c) If StringRegExp($sRoot, "^[[:alpha:]]*(\|[[:alpha:]])?$") Then ; Set list to uppercase $sRoot = StringUpper($sRoot) ; Split to look for eventual default drive Local $aSplit = StringSplit($sRoot, "|") ; Set required drive list $sDrives = $aSplit[1] ; Check for default drive If $aSplit[0] = 2 Then $sDefDrive = $aSplit[2] ; Check if default in drive list If $sDrives And Not StringInStr($sDrives, $sDefDrive) Then ; Clear if not $sDefDrive = "" Else ; Add colon $sDefDrive &= ":" EndIf EndIf ; Clear root parameter to get combo displayed $sRoot = "" Else ; Not valid path or drive list Return SetError(1, 0, "") EndIf EndIf EndSwitch ; Get array of network drives - to show indexing label if required Local $aNetwork_Drives = DriveGetDrive("NETWORK") If @error Then Local $aNetwork_Drives[1] = [0] EndIf ; Check Mask If $sMask = Default Then $sMask = "*" EndIf ; Extract File mask (needed for hide extension code) Local $aMaskSplit = StringSplit($sMask, "|") Local $sFile_Mask = $aMaskSplit[1] ; Check Display parameter $iDisplay = _CFF_Check_Display($iDisplay, $sFile_Mask, $fShow_Ext, $iHide_HS, $fBoth_Selectable, $fDuplicates_Allowed) If @error Then Return SetError(2, 0, "") EndIf ; Check selection type and list size Local $fSingle_Sel = False Local $iList_Percent = .2 Switch $iMultiple Case 0, Default $fSingle_Sel = True Case 10 To 50 $iList_Percent = .01 * $iMultiple EndSwitch ; Check parent Switch $hParent Case 0 Case Else If Not IsHWnd($hParent) Then Return SetError(3, 0, "") EndSwitch ; Check for width and height minima and set button size Local $iButton_Width If $fSingle_Sel Then If $iW < 130 Then $iW = 130 $iButton_Width = Int(($iW - 30) / 2) Else If $iW < 250 Then $iW = 250 $iButton_Width = Int(($iW - 50) / 4) EndIf If $iButton_Width > 80 Then $iButton_Width = 80 If $iH < 300 Then $iH = 300 ; Create dialog Local $hCFF_Win = GUICreate($sTitle, $iW, $iH, $iX, $iY, 0x80C80000, -1, $hParent) ; BitOR($WS_POPUPWINDOW, $WS_CAPTION) If @error Then Return SetError(4, 0, "") GUISetBkColor(0xCECECE) ; Declare variables Local $cCan_Button, $cSel_Button = 9999, $cAdd_Button = 9999, $cDel_Button = 9999, $cRet_Button = 9999 Local $cTreeView = 9999, $hTreeView = 9999, $cList = 9999, $cDrive_Combo = 9999 Local $sCurrDrive = "", $sSelectedPath, $iList_Height, $iTV_Height, $sAddFile_List = "" Local $cItem, $hItem ; Create buttons If $fSingle_Sel Then $cSel_Button = GUICtrlCreateButton("Select", $iW - ($iButton_Width + 10), $iH - 40, $iButton_Width, 30) Else $cAdd_Button = GUICtrlCreateButton("Add", 10, $iH - 40, $iButton_Width, 30) $cDel_Button = GUICtrlCreateButton("Delete", $iButton_Width + 20, $iH - 40, $iButton_Width, 30) $cRet_Button = GUICtrlCreateButton("Return", $iW - ($iButton_Width + 10), $iH - 40, $iButton_Width, 30) EndIf $cCan_Button = GUICtrlCreateButton("Cancel", $iW - ($iButton_Width + 10) * 2, $iH - 40, $iButton_Width, 30) ; Create controls Select Case $sRoot And $fSingle_Sel ; TV only ; Create TV and hide $cTreeView = GUICtrlCreateTreeView(10, 10, $iW - 20, $iH - 60) $hTreeView = GUICtrlGetHandle($cTreeView) GUICtrlSetState(-1, 32) ; $GUI_HIDE Case Not $sRoot And $fSingle_Sel ; Combo and TV ; Create and fill Combo $cDrive_Combo = _CFF_Combo_Fill($iW, $sDrives, $sDefDrive) ; Create TV and hide $cTreeView = GUICtrlCreateTreeView(10, 40, $iW - 20, $iH - 90) $hTreeView = GUICtrlGetHandle($cTreeView) GUICtrlSetState(-1, 32) ; $GUI_HIDE Case $sRoot And Not $fSingle_Sel ; TV and List ; Calculate control heights $iList_Height = Int(($iH - 60) * $iList_Percent) If $iList_Height < 40 Then $iList_Height = 40 EndIf $iTV_Height = $iH - $iList_Height - 60 ; Create TV and hide $cTreeView = GUICtrlCreateTreeView(10, 10, $iW - 20, $iTV_Height) $hTreeView = GUICtrlGetHandle($cTreeView) GUICtrlSetState(-1, 32) ; $GUI_HIDE ; Create List $cList = GUICtrlCreateList("", 10, 10 + $iTV_Height, $iW - 20, $iList_Height, 0x00A04100) ;BitOR($WS_BORDER, $WS_VSCROLL, $LBS_NOSEL, $LBS_NOINTEGRALHEIGHT)) Case Not $sRoot And Not $fSingle_Sel ; Combo, TV and List ; Calculate control heights $iList_Height = Int(($iH - 90) * $iList_Percent) If $iList_Height < 40 Then $iList_Height = 40 EndIf $iTV_Height = $iH - $iList_Height - 90 ; Create and fill Combo $cDrive_Combo = _CFF_Combo_Fill($iW, $sDrives, $sDefDrive) ; Create TV and hide $cTreeView = GUICtrlCreateTreeView(10, 40, $iW - 20, $iTV_Height) $hTreeView = GUICtrlGetHandle($cTreeView) GUICtrlSetState(-1, 32) ; $GUI_HIDE ; Create List $cList = GUICtrlCreateList("", 10, 40 + $iTV_Height, $iW - 20, $iList_Height, 0x00A04100) ;BitOR($WS_BORDER, $WS_VSCROLL, $LBS_NOSEL, $LBS_NOINTEGRALHEIGHT)) EndSelect ; Create dummy control to fire when [+] clicked $cCFF_Expand_Dummy = GUICtrlCreateDummy() ; Create dummy control to for on DblClk $cCFF_DblClk_Dummy = GUICtrlCreateDummy() ; Display dialog GUISetState() ; Set required default drive if required If $sDefDrive Then ; Set default drive as root $sRoot = $sDefDrive & "\" ; Show in combo GUICtrlSetData($cDrive_Combo, $sDefDrive) EndIf ; Fill tree If $sRoot Then ; If root folder specified then fill TV _CFF_Fill_Branch($cTreeView, $cTreeView, $sRoot, $iDisplay, $sMask, $fShow_Ext, $iHide_HS, $aNetwork_Drives) ; Show TV GUICtrlSetState($cTreeView, 16) ; $GUI_SHOW EndIf ; Change to MessageLoop mode Local $nOldOpt = Opt('GUIOnEventMode', 0) While 1 Switch GUIGetMsg() Case $cCan_Button, -3 ; $GUI_EVENT_CLOSE GUIDelete($hCFF_Win) ; Restore previous mode Opt('GUIOnEventMode', $nOldOpt) Return SetError(5, 0, "") Case $cCFF_DblClk_Dummy ; Check doubleclick selection is permitted (not default for folders only) If $iDisplay = 2 Then ; Not permitted ElseIf $iDisplay = 3 Then ; Check if any children $cItem = GUICtrlRead($cTreeView) $hItem = GUICtrlGetHandle($cItem) If _GUICtrlTreeView_GetChildCount($hTreeView, $hItem) < 1 Then ; No children so selection permitted ContinueCase EndIf Else ; Permitted ContinueCase EndIf Case $cSel_Button, $cAdd_Button ; Check if Ctrl pressed _WinAPI_GetAsyncKeyState(0x11) ; Needed to avoid double setting If _WinAPI_GetAsyncKeyState(0x11) Then ; Run delete code ContinueCase EndIf ; Get item data $cItem = GUICtrlRead($cTreeView) $hItem = GUICtrlGetHandle($cItem) ; Determine item path $sSelectedPath = $sRoot & StringReplace(_GUICtrlTreeView_GetTree($hTreeView, $hItem), "|", "\") ; Check path is a valid selection $sSelectedPath = _CFF_Check_Selection($iDisplay, $sSelectedPath, $fBoth_Selectable, $fShow_Ext, $sFile_Mask) If $sSelectedPath Then ; Valid item selected If $fSingle_Sel Then GUIDelete($hCFF_Win) ; Restore previous mode Opt('GUIOnEventMode', $nOldOpt) ; Return valid path Return $sSelectedPath Else $sAddFile_List = _CFF_List_Add($sAddFile_List, $sSelectedPath, $cList, $fDuplicates_Allowed, $cTreeView) EndIf EndIf Case $cDel_Button ; Get item data $cItem = GUICtrlRead($cTreeView) $hItem = GUICtrlGetHandle($cItem) ; Determine item path $sSelectedPath = $sRoot & StringReplace(_GUICtrlTreeView_GetTree($hTreeView, $hItem), "|", "\") ; Check path is a valid selection $sSelectedPath = _CFF_Check_Selection($iDisplay, $sSelectedPath, $fBoth_Selectable, $fShow_Ext, $sFile_Mask) If $sSelectedPath Then ; Valid item selected $sAddFile_List = _CFF_List_Del($sAddFile_List, $sSelectedPath, $cList, $cTreeView) EndIf Case $cRet_Button GUIDelete($hCFF_Win) ; Restore previous mode Opt('GUIOnEventMode', $nOldOpt) ; Remove final | from return string and return Return StringTrimRight($sAddFile_List, 1) Case $cCFF_Expand_Dummy ; Get expanded item hamdle $hItem = GUICtrlRead($cCFF_Expand_Dummy) If $hItem Then ; Select item _GUICtrlTreeView_ClickItem($hTreeView, $hItem) ; Get expanded item data $cItem = GUICtrlRead($cTreeView) $hItem = GUICtrlGetHandle($cItem) $sSelectedPath = $sRoot & StringReplace(_GUICtrlTreeView_GetTree($cTreeView, $hItem), "|", "\") ; Check if dummy child exists or has already been filled Local $hFirstChild = _GUICtrlTreeView_GetFirstChild($hTreeView, $hItem) Local $sFirstChild = _GUICtrlTreeView_GetText($hTreeView, $hFirstChild) ; If dummy child exists If $sFirstChild = "" Then ; Fill with content _CFF_Fill_Branch($cTreeView, $cItem, $sSelectedPath, $iDisplay, $sMask, $fShow_Ext, $iHide_HS, $aNetwork_Drives) ; Delete the dummy _GUICtrlTreeView_Delete($hTreeView, $hFirstChild) ;Else ; Either already filled or empty EndIf ; Clear the flag to reactivate the handler GUICtrlSendToDummy($cCFF_Expand_Dummy, 0) EndIf Case $cDrive_Combo If GUICtrlRead($cDrive_Combo) <> $sCurrDrive Then ; Get drive chosen $sCurrDrive = GUICtrlRead($cDrive_Combo) If $sRoot Then ; Delete current content _GUICtrlTreeView_DeleteAll($hTreeView) Else ; Show TV GUICtrlSetState($cTreeView, 16) ; $GUI_SHOW EndIf ; Set root path $sRoot = $sCurrDrive & "\" ; Fill TV _CFF_Fill_Branch($cTreeView, $cTreeView, $sRoot, $iDisplay, $sMask, $fShow_Ext, $iHide_HS, $aNetwork_Drives) EndIf EndSwitch WEnd EndFunc ;==>_CFF_Choose ; #FUNCTION# ========================================================================================================= ; Name...........: _CFF_Embed ; Description ...: Creates the folder tree within an existing treeview and optional list ; Syntax.........: _CFF_Embed ($cTreeView, $sRoot[, $sMask = "*"[, $iDisplay = 0[, $cReturn = 0[, $cList = 0]]]) ; Parameters ....: $cTreeView - Handle/ControlID of TreeView to use ; $sRoot - Path tree to display ; $sMask - Filter for result. Multiple filters must be separated by ";" ; Use "|" to separate 3 possible sets of filters: "Include|Exclude|Exclude_Folders" ; Include = Files/Folders to include (default = "*" [all]) ; Exclude = Files/Folders to exclude (default = "" [none]) ; Exclude_Folders = only used if the basic $iDisplay = 0 to exclude defined folders (default = "" [none]) ; $iDisplay - Determine what is displayed in the tree ; 0 - Entire folder tree and all matching files within folders - only files can be selected ; 1 - All matching files within the specified folder - subfolders are not displayed ; 2 - Entire folder tree only - no files. Doubleclicks will expand, not select, item ; 3 - As 2 but doubleclicks will select item if it has no children ; + 4 - Do not display Hidden files/folders ; + 8 - Do not display System files/folders ; + 16 - Both files and folders cab be selected - only valid if $iDisplay set to 0 ; + 32 - Allow duplicate selections ; + 64 - Hide file extensions (only valid if file mask specifies a single extension) ; $cReturn - Set single/multiple selection ; 0 - Single selection (default). Doubleclick returns item - @extended set to 0 ; 1 - Multiple selection. Doubleclick adds item to return string ; Valid ControlID - Control to action to end multiple selection - @extended set to 0 ; $cList - [Optional] ControlID of list to fill with multiple selections ; Requirement(s).: v3.3 + ; Return values .: Success: Single selection = String containing selected item ; Multi selection = String of selected items delimited by "|" ; Failure: Returns "" and sets @error as follows: ; 1 = Invalid TreeView ControlID ; 2 = Path does not exist ; 3 = Invalid $iDisplay parameter ; 4 = Invalid $cList ControlID ; 5 = Invalid or missing $cReturn ControlID ; 6 = Empty tree ; 7 = Esc pressed to exit ; Author ........: Melba23 ; Modified ......: ; Remarks .......: - If files are displayed, only files can be selected ; - Press ESC to cancel selection ; - Press Enter to return current selection - @extended set to 1 ; - Pressing CTRL while selecting deletes last instance of item from selection ; Example........: Yes ;===================================================================================================================== Func _CFF_Embed($cTreeView, $sRoot, $sMask = "*", $iDisplay = 0, $cReturn = 0, $cList = 0) Local $fSingle_Sel, $hTreeView, $cItem, $hItem, $sSelectedPath, $sAddFile_List = "" Local $fShow_Ext = True, $iHide_HS = 0, $fBoth_Selectable = False, $fDuplicates_Allowed = False ; Check treeview type Local $fNative_TV = True If IsHWnd($cTreeView) Then $hTreeView = $cTreeView $fNative_TV = False Else If Not IsHWnd(GUICtrlGetHandle($cTreeView)) Then Return SetError(1, 0, "") Else $hTreeView = GUICtrlGetHandle($cTreeView) EndIf EndIf ; Check path If Not FileExists($sRoot) Then Return SetError(2, 0, "") EndIf If StringRight($sRoot, 1) <> "\" Then $sRoot &= "\" EndIf ; Get array of network drives Local $aNetwork_Drives = DriveGetDrive("NETWORK") If @error Then Local $aNetwork_Drives[1] = [0] EndIf ; Check Mask If $sMask = Default Then $sMask = "*" EndIf ; Extract File mask (needed for hide extension code) Local $aMaskSplit = StringSplit($sMask, "|") Local $sFile_Mask = $aMaskSplit[1] ; Check Display parameter $iDisplay = _CFF_Check_Display($iDisplay, $sFile_Mask, $fShow_Ext, $iHide_HS, $fBoth_Selectable, $fDuplicates_Allowed) If @error Then Return SetError(3, 0, "") EndIf ; Check return control Switch $cReturn Case 0 ; Single select $fSingle_Sel = True ; Prevent from firing $cReturn = 9999 Case Else ; Multi select $fSingle_Sel = False ; Check if valid ControlID If Not IsHWnd(GUICtrlGetHandle($cReturn)) Then ; Prevent from firing $cReturn = 9999 EndIf EndSwitch ; If list passed check if valid ControlID If $cList And Not IsHWnd(GUICtrlGetHandle($cList)) Then Return SetError(5, 0, "") EndIf ; Fill treeview If Not _CFF_Fill_Branch($cTreeView, $cTreeView, $sRoot, $iDisplay, $sMask, $fShow_Ext, $iHide_HS, $aNetwork_Drives) Then Return SetError(6, 0, "") EndIf ; Create dummy controls to fire when $cCFF_Expand_Dummy = GUICtrlCreateDummy() ; fires when [+] clicked $cCFF_DblClk_Dummy = GUICtrlCreateDummy() ; fires on DblClk Local $cRet_Dummy = GUICtrlCreateDummy() ; fires on ENTER Local $cEsc_Dummy = GUICtrlCreateDummy() ; fires on ESC ; Create accel key array Local $aAccelKeys[2][2] = [["{ENTER}", $cRet_Dummy],["{ESC}", $cEsc_Dummy]] ; Set accel keys GUISetAccelerators($aAccelKeys) ; Change to MessageLoop mode Local $nOldOpt = Opt('GUIOnEventMode', 0) ; Clear flag for Ret key pressed Local $iRet_Pressed = 0 While 1 Switch GUIGetMsg() Case $cRet_Dummy ; Set flag $iRet_Pressed = 1 If $fSingle_Sel Then ; Read selected item $hItem = GUICtrlGetHandle(GUICtrlRead($cTreeView)) If $hItem Then ; Determine item path $sAddFile_List = $sRoot & StringReplace(_GUICtrlTreeView_GetTree($hTreeView, $hItem), "|", "\") Switch $iDisplay Case 2 ; Folders only Case Else ; Files only StringReplace(FileGetAttrib($sAddFile_List), "D", "") ; Is it a folder? If @extended Then $sAddFile_List = "" EndIf ; Hide extension? If $fShow_Ext = False Then $sAddFile_List &= StringTrimLeft($sFile_Mask, 1) EndIf EndSwitch EndIf ; Else ; $sAddFile_List already filled EndIf ContinueCase Case $cReturn ; Clear treeview and list _GUICtrlTreeView_DeleteAll($cTreeView) GUICtrlSetData($cList, "|") ; Restore previous mode Opt('GUIOnEventMode', $nOldOpt) ; Cancel Accel keys GUISetAccelerators(0) ; Return list of files selected Return SetError(0, $iRet_Pressed, $sAddFile_List) Case $cCFF_DblClk_Dummy ; Clear flag Local $fPermit = False ; Check doubleclick selection is permitted (not default for folders only) If $iDisplay = 2 Then ; Not permitted ElseIf $iDisplay = 3 Then ; Check if any children $cItem = GUICtrlRead($cTreeView) $hItem = GUICtrlGetHandle($cItem) If _GUICtrlTreeView_GetChildCount($hTreeView, $hItem) < 1 Then ; No children so selection permitted $fPermit = True EndIf Else ; Permitted $fPermit = True EndIf ; If selection permitted If $fPermit Then ; Get item data If $fNative_TV Then $hItem = GUICtrlGetHandle(GUICtrlRead($cTreeView)) Else $hItem = _GUICtrlTreeView_GetSelection($hTreeView) EndIf ; Determine item path $sSelectedPath = $sRoot & StringReplace(_GUICtrlTreeView_GetTree($hTreeView, $hItem), "|", "\") ; Check path is a valid selection $sSelectedPath = _CFF_Check_Selection($iDisplay, $sSelectedPath, $fBoth_Selectable, $fShow_Ext, $sFile_Mask) If $sSelectedPath Then ; Valid item selected If $fSingle_Sel Then ; Clear treeview _GUICtrlTreeView_DeleteAll($cTreeView) ; Restore previous mode Opt('GUIOnEventMode', $nOldOpt) ; Cancel Accel keys GUISetAccelerators(0) ; Return valid path Return $sSelectedPath Else ; Check if Ctrl pressed _WinAPI_GetAsyncKeyState(0x11) ; Needed to avoid double setting If _WinAPI_GetAsyncKeyState(0x11) Then $sAddFile_List = _CFF_List_Del($sAddFile_List, $sSelectedPath, $cList, $cTreeView) Else $sAddFile_List = _CFF_List_Add($sAddFile_List, $sSelectedPath, $cList, $fDuplicates_Allowed, $cTreeView) EndIf EndIf EndIf EndIf Case $cCFF_Expand_Dummy ; Get expanded item hamdle $hItem = GUICtrlRead($cCFF_Expand_Dummy) If $hItem Then ; Select item _GUICtrlTreeView_ClickItem($hTreeView, $hItem) ; Get expanded item data If $fNative_TV Then $cItem = GUICtrlRead($cTreeView) $hItem = GUICtrlGetHandle($cItem) Else $hItem = _GUICtrlTreeView_GetSelection($hTreeView) $cItem = $hItem EndIf $sSelectedPath = $sRoot & StringReplace(_GUICtrlTreeView_GetTree($cTreeView, $hItem), "|", "\") ; Check if dummy child exists or has already been filled Local $hFirstChild = _GUICtrlTreeView_GetFirstChild($hTreeView, $hItem) Local $sFirstChild = _GUICtrlTreeView_GetText($hTreeView, $hFirstChild) ; If dummy child exists If $sFirstChild = "" Then ; Fill with content _CFF_Fill_Branch($cTreeView, $cItem, $sSelectedPath, $iDisplay, $sMask, $fShow_Ext, $iHide_HS, $aNetwork_Drives) ; Delete the dummy _GUICtrlTreeView_Delete($hTreeView, $hFirstChild) ;Else ; Either already filled or empty EndIf ; Clear the flag to reactivate the handler GUICtrlSendToDummy($cCFF_Expand_Dummy, 0) EndIf Case $cEsc_Dummy ; Clear treeview and list _GUICtrlTreeView_DeleteAll($cTreeView) GUICtrlSetData($cList, "|") ; Restore previous mode Opt('GUIOnEventMode', $nOldOpt) ; Cancel Accel keys GUISetAccelerators(0) ; Return Return SetError(7, 0, "") EndSwitch WEnd EndFunc ;==>_CFF_Embed ; #FUNCTION# ========================================================================================================= ; Name...........: _CFF_RegMsg ; Description ...: Registers WM_NOTIFY to action doubleclick and item expansion on TreeView ; Syntax.........: _CFF_RegMsg() ; Parameteres....: None ; Requirement(s).: v3.3 + ; Return values .: Success: 1 ; Failure: 0 ; Author ........: Melba23 ; Modified ......: ; Remarks .......: If the script already has a WM_NOTIFY handler then call the _CFF_WM_NOTIFY_Handler function ; from within it ; Example........: Yes ;===================================================================================================================== Func _CFF_RegMsg() Return GUIRegisterMsg(0x004E, "_CFF_WM_NOTIFY_Handler") ; $WM_NOTIFY EndFunc ;==>_CFF_RegMsg ; #FUNCTION# ========================================================================================================= ; Name...........: _CFF_WM_NOTIFY_Handler ; Description ...: Windows message handler for WM_NOTIFY - reacts to doubleclick and item expansion on TreeView ; Syntax.........: _CFF_WM_NOTIFY_Handler($hWnd, $iMsg, $wParam, $lParam) ; Requirement(s).: v3.3 + ; Return values..: None ; Author ........: Melba23 - thanks to guinness for help with the #*@#*%# Struct !!!! ; Modified ......: ; Remarks .......: If a WM_NOTIFY handler already registered, then call this function from within that handler ; Example........: Yes ;===================================================================================================================== Func _CFF_WM_NOTIFY_Handler($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam ; Create NMTREEVIEW structure Local $tStruct = DllStructCreate("struct;hwnd hWndFrom;uint_ptr IDFrom;INT Code;endstruct;" & _ "uint Action;struct;uint OldMask;handle OldhItem;uint OldState;uint OldStateMask;" & _ "ptr OldText;int OldTextMax;int OldImage;int OldSelectedImage;int OldChildren;lparam OldParam;endstruct;" & _ "struct;uint NewMask;handle NewhItem;uint NewState;uint NewStateMask;" & _ "ptr NewText;int NewTextMax;int NewImage;int NewSelectedImage;int NewChildren;lparam NewParam;endstruct;" & _ "struct;long PointX;long PointY;endstruct", $lParam) Local $hItem = DllStructGetData($tStruct, 'NewhItem') Local $ID = DllStructGetData($tStruct, 'Code') Switch $ID Case 0xFFFFFFFD ; $NM_DBLCLK ; Fire the dummy control GUICtrlSendToDummy($cCFF_DblClk_Dummy) Case $TVN_ITEMEXPANDEDW, $TVN_ITEMEXPANDEDA ; Check that expansion is not ongoing If GUICtrlRead($cCFF_Expand_Dummy) = 0 Then ; Fire the dummy control GUICtrlSendToDummy($cCFF_Expand_Dummy, $hItem) EndIf EndSwitch EndFunc ;==>_CFF_WM_NOTIFY_Handler ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name...........: _CFF_Combo_Fill ; Description ...: Creates and fills a combo to allow drive selection. ; Author ........: Melba23 ; Remarks .......: ; =============================================================================================================================== Func _CFF_Combo_Fill($iW, $sDrives, ByRef $sDefDrive) Local $iInset = Int(($iW - 170) / 2), $aDrives GUICtrlCreateLabel("Select Drive:", 10 + $iInset, 15, 65, 20) Local $cCombo = GUICtrlCreateCombo("", 75 + $iInset, 10, 50, 20) ; Create drive array If $sDrives Then ; Use specified drive list $aDrives = StringSplit($sDrives, "") For $i = 1 To $aDrives[0] $aDrives[$i] &= ":" Next Else ; If no drives specified then list all $aDrives = DriveGetDrive("ALL") EndIf ; Add drives to combo For $i = 1 To $aDrives[0] ; Only display ready drives If DriveStatus($aDrives[$i] & '\') == "READY" Then GUICtrlSetData($cCombo, StringUpper($aDrives[$i])) Else ; If default drive not ready If $sDefDrive = $aDrives[$i] Then ; Clear it $sDefDrive = "" EndIf EndIf Next Return $cCombo EndFunc ;==>_CFF_Combo_Fill ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name...........: _CFF_Fill_Branch ; Description ...: Fills a TreeView branch with folders and files on expansion ; Author ........: Melba23 ; Remarks .......: ; =============================================================================================================================== Func _CFF_Fill_Branch($cTV, $cParent, $sPath, $iDisplay, $sMask, $fShow_Ext, $iHide_HS, $aNetwork_Drives) Local $hTV, $sFolder_Mask, $sItem, $cItem, $hSearch, $fFound = False ; Check if network drive Local $sDrive = StringLeft($sPath, 2) For $i = 1 To $aNetwork_Drives[0] If $aNetwork_Drives[$i] = $sDrive Then Local $aTV_Pos = WinGetPos(GUICtrlGetHandle($cTV)) SplashTextOn("", "Indexing from" & @CRLF & "Network drive..." & @CRLF & @CRLF & "Please be patient", $aTV_Pos[2], $aTV_Pos[3], $aTV_Pos[0], $aTV_Pos[1], 33) EndIf Next ; Check if native or UDF TV Local $fNative_TV = True If IsHWnd($cTV) Then $fNative_TV = False $hTV = $cTV Else $hTV = GUICtrlGetHandle($cTV) EndIf ; Force path with trailing \ If StringRight($sPath, 1) <> "\" Then $sPath &= "\" EndIf ; Expand TV _GUICtrlTreeView_BeginUpdate($hTV) ; Search for folders if required Switch $iDisplay Case 0, 2, 3 ; Set mask for folder search $sFolder_Mask = $sMask ; This is valid for folder only search If $iDisplay = 0 Then ; For file and folder search look for a folder_Exclude parameter Local $aMaskSplit = StringSplit($sMask, "|") If $aMaskSplit[0] = 3 Then ; And use it if found $sFolder_Mask = "*|" & $aMaskSplit[3] Else $sFolder_Mask = "*" EndIf EndIf ; Now list folders Local $aContent = _RecFileListToArray($sPath, $sFolder_Mask, 2 + $iHide_HS, 0, 1, 1) If IsArray($aContent) Then For $i = 1 To $aContent[0] ; Remove trailing \ if needed $sItem = $aContent[$i] If StringRight($sItem, 1) = "\" Then $sItem = StringTrimRight($sItem, 1) EndIf ; Create item If $fNative_TV Then $cItem = GUICtrlCreateTreeViewItem($sItem, $cParent) Else ; Use correct function depending on TV type If $cParent = $hTV Then $cItem = _GUICtrlTreeView_Add($hTV, $cParent, $sItem) Else $cItem = _GUICtrlTreeView_AddChild($hTV, $cParent, $sItem) EndIf EndIf ; Look for content within the folder FileChangeDir($sPath & $aContent[$i]) $hSearch = FileFindFirstFile("*.*") ; If there is something If $hSearch <> -1 Then ; Set flag $fFound = True ; Need to determine type of content? Switch $iDisplay Case 0 ; Either folder or file ; Create dummy child to force [+] display If $fNative_TV Then GUICtrlCreateTreeViewItem("", $cItem) Else _GUICtrlTreeView_AddChild($hTV, $cItem, "") EndIf Case Else While 1 FileFindNextFile($hSearch) ; End of content If @error Then ExitLoop Local $iExtended = @extended Switch $iDisplay Case 1 ; Files only If Not $iExtended Then ; Found file If $fNative_TV Then GUICtrlCreateTreeViewItem("", $cItem) Else _GUICtrlTreeView_AddChild($hTV, $cItem, "") EndIf ; No need to look further ExitLoop EndIf Case Else ; Folders only If $iExtended Then ; Found folder If $fNative_TV Then GUICtrlCreateTreeViewItem("", $cItem) Else _GUICtrlTreeView_AddChild($hTV, $cItem, "") EndIf ; No need to look further ExitLoop EndIf EndSwitch WEnd ; Close search FileClose($hSearch) EndSwitch EndIf FileChangeDir(@ScriptDir) Next EndIf EndSwitch ; Search for files if required Switch $iDisplay Case 0, 1 ; List files $aContent = _RecFileListToArray($sPath, $sMask, 1 + $iHide_HS, 0, 1) If IsArray($aContent) Then ; Set flag $fFound = True For $i = 1 To $aContent[0] $sItem = $aContent[$i] ; Remove extension if required If Not $fShow_Ext Then $sItem = StringRegExpReplace($sItem, "(.*)\..*", "$1") EndIf ; Create item If $fNative_TV Then GUICtrlCreateTreeViewItem($sItem, $cParent) Else ; Use correct function depending on TV type If $cParent = $hTV Then $cItem = _GUICtrlTreeView_Add($hTV, $cParent, $sItem) Else $cItem = _GUICtrlTreeView_AddChild($hTV, $cParent, $sItem) EndIf EndIf Next EndIf EndSwitch _GUICtrlTreeView_EndUpdate($hTV) ; Hide Splash if used SplashOff() Return $fFound EndFunc ;==>_CFF_Fill_Branch ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name...........: _CFF_Check_Display ; Description ...: Checks for valid Dispaly parameter ; Author ........: Melba23 ; Remarks .......: ; =============================================================================================================================== Func _CFF_Check_Display($iDisplay, $sFile_Mask, ByRef $fShow_Ext, ByRef $iHide_HS, ByRef $fBoth_Selectable, ByRef $fDuplicates_Allowed) ; Show hidden and system files If BitAND($iDisplay, 4) Then $iHide_HS += 4 $iDisplay -= 4 EndIf If BitAND($iDisplay, 8) Then $iHide_HS += 8 $iDisplay -= 8 EndIf ; Both files and folders selectable If BitAND($iDisplay, 16) Then $fBoth_Selectable = True $iDisplay -= 16 EndIf ; Allow duplicate selections If BitAND($iDisplay, 32) Then $fDuplicates_Allowed = True $iDisplay -= 32 EndIf ; Hide file extensions? If BitAND($iDisplay, 64) Then $iDisplay -= 64 ; Check that only one ext is specified StringReplace($sFile_Mask, ";", "") Local $iExt = @extended If $sFile_Mask <> "*.*" And $iExt = 0 Then ; File exts hidden $fShow_Ext = False EndIf EndIf ; Check valid parameter Switch $iDisplay Case 0 To 3 Return $iDisplay Case Else Return SetError(1, 0, 0) EndSwitch EndFunc ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name...........: _CFF_Check_Valid ; Description ...: Checks selection is valid ; Author ........: Melba23 ; Remarks .......: ; =============================================================================================================================== Func _CFF_Check_Selection($iDisplay, $sSelectedPath, $fBoth_Selectable, $fShow_Ext, $sFile_Mask) Switch $iDisplay Case 0 ; Files and folders displayed ; Is it a folder? Local $fFolder = False StringReplace(FileGetAttrib($sSelectedPath), "D", "") If @extended Then $fFolder = True EndIf ; Both selectable? If $fBoth_Selectable Then If $fFolder Then $sSelectedPath &= "\" Else ; Check as a file ContinueCase EndIf Else ; Only files can be selected If $fFolder Then $sSelectedPath = "" Else ContinueCase EndIf EndIf Case 1 ; Only files displayed ; Hide extension? If $fShow_Ext = False Then $sSelectedPath &= StringTrimLeft($sFile_Mask, 1) EndIf ;Case 2, 3 ; Only folders displayed EndSwitch Return $sSelectedPath EndFunc ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name...........: _CFF_List_Add ; Description ...: Adds item to return list ; Author ........: Melba23 ; Remarks .......: ; =============================================================================================================================== Func _CFF_List_Add($sAddFile_List, $sSelectedPath, $cList, $fDuplicates_Allowed, $cTreeView) ; Check for existing instance in list If StringInStr($sAddFile_List, $sSelectedPath & "|") Then ; If duplicates are allowed If $fDuplicates_Allowed Then ; Add to return string $sAddFile_List &= $sSelectedPath & "|" ; Add to onscreen list GUICtrlSendMsg($cList, 0x0180, 0, $sSelectedPath) ; $LB_ADDSTRING EndIf Else ; Add to return string $sAddFile_List &= $sSelectedPath & "|" ; Add to onscreen list GUICtrlSendMsg($cList, 0x0180, 0, $sSelectedPath) ; $LB_ADDSTRING EndIf ; Scroll to bottom of list GUICtrlSendMsg($cList, 0x197, GUICtrlSendMsg($cList, 0x18B, 0, 0) - 1, 0) ; $LB_SETTOPINDEX, $LB_GETCOUNT ; Return focus to TV GUICtrlSetState($cTreeView, 256) ; $GUI_FOCUS Return $sAddFile_List EndFunc ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name...........: _CFF_List_Del ; Description ...: Deletes item from return list ; Author ........: Melba23 ; Remarks .......: ; =============================================================================================================================== Func _CFF_List_Del($sAddFile_List, $sSelectedPath, $cList, $cTreeView) ; Check for existing instance in list If StringInStr($sAddFile_List, $sSelectedPath & "|") Then ; Delete last instance of item $sAddFile_List = StringReplace($sAddFile_List, $sSelectedPath & "|", "", -1) ; Replace list content with new list GUICtrlSetData($cList, "|" & $sAddFile_List) EndIf ; Scroll to bottom of list GUICtrlSendMsg($cList, 0x197, GUICtrlSendMsg($cList, 0x18B, 0, 0) - 1, 0) ; $LB_SETTOPINDEX, $LB_GETCOUNT ; Return focus to TV GUICtrlSetState($cTreeView, 256) ; $GUI_FOCUS Return $sAddFile_List EndFuncComments from anyone else also welcome of course! M23* Not really - although I was tempted. 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Tankbuster Posted August 2, 2013 Share Posted August 2, 2013 Wonderful "wait" dialog -- great job - "bloody wait" ---- maybe add it as easter egg on Halloween round midnight :-) The DELETE button looks nice. But It work snot as close as I thought: Working: ADD file 1 ADD file 2 REMOVE button (File 2 is gone) REMOVE button (nothing happens) I would like to have (yes, show me the little finger and I take the complete arm :-) ) If no file is selected in the selection box, remove always the last entry. If a file is selected in the list box, remove the file selected..... And I use Vista+ (= Windows 7) - what's the name of the other 12 year old OS again ? So I'm open for "new" style. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 2, 2013 Author Moderators Share Posted August 2, 2013 Tankbuster,At the moment you add or delete the file selected in the TreeView - adding the ability to select and delete files from the list would complicate the code horribly and is, in my opinion, a step too far. You will have to put up with the arm only as far as the elbow! I was considering a split button, but I have gone with the additional button as it meant less code. Just for interest, you can see what they look like here:expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiButton.au3> #include <WindowsConstants.au3> #include <GuiMenu.au3> Global $hButton_1, $hButton_2, $hButton_1_Handle _Main() Func _Main() Local $hGUI $hGUI = GUICreate("Buttons", 400, 400) $hButton_1 = GUICtrlCreateButton("Initial 1", 10, 10, 120, 30, $BS_SPLITBUTTON) $hButton_1_Handle = GUICtrlGetHandle(-1) $hButton_2 = _GUICtrlButton_Create($hGUI, "Initial 1", 270, 10, 120, 30, $BS_SPLITBUTTON) _GUICtrlButton_SetSplitInfo($hButton_2) ; puts icon to left GUISetState() GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $hButton_1 ConsoleWrite("Button 1 Pressed - " & GUICtrlRead($hButton_1) & @CRLF) EndSwitch WEnd Exit EndFunc ;==>_Main Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) #forceref $hWnd, $Msg, $wParam Local $tNMBHOTITEM = DllStructCreate("hwnd hWndFrom;int IDFrom;int Code;dword dwFlags", $lParam) Local $nNotifyCode = DllStructGetData($tNMBHOTITEM, "Code") ;Local $nID = DllStructGetData($tNMBHOTITEM, "IDFrom") Local $hCtrl = DllStructGetData($tNMBHOTITEM, "hWndFrom") ;Local $dwFlags = DllStructGetData($tNMBHOTITEM, "dwFlags") Switch $nNotifyCode Case $BCN_DROPDOWN _Popup_Menu($hCtrl) EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func _Popup_Menu($hCtrl) Local Enum $iOption_1 = 1000, $iOption_2 Local $hMenu = _GUICtrlMenu_CreatePopup() _GUICtrlMenu_InsertMenuItem($hMenu, 0, "Disable", $iOption_1) _GUICtrlMenu_InsertMenuItem($hMenu, 1, "Enable", $iOption_2) Switch _GUICtrlMenu_TrackPopupMenu($hMenu, $hCtrl, -1, -1, 1, 1, 2) Case $iOption_1 Switch $hCtrl Case $hButton_1_Handle ConsoleWrite("Button 1 - Option 1" & @CRLF) GUICtrlSetData($hButton_1, "Option 1") _GUICtrlButton_Enable($hButton_2, False) ; <<<<<<<<<<<<<<<<<<<<<<<< Case $hButton_2 ConsoleWrite("Button 2 - Option 1" & @CRLF) _GUICtrlButton_SetText($hButton_2, "Option 1") GUICtrlSetState($hButton_1, $GUI_DISABLE) ; <<<<<<<<<<<<<<<<<<<<<<<< EndSwitch Case $iOption_2 Switch $hCtrl Case $hButton_1_Handle ConsoleWrite("Button 1 - Option 2" & @CRLF) GUICtrlSetData($hButton_1, "Option 2") _GUICtrlButton_Enable($hButton_2, True) ; <<<<<<<<<<<<<<<<<<<<<<<< Case $hButton_2 ConsoleWrite("Button 2 - Option 2" & @CRLF) _GUICtrlButton_SetText($hButton_2, "Option 2") GUICtrlSetState($hButton_1, $GUI_ENABLE) ; <<<<<<<<<<<<<<<<<<<<<<<< EndSwitch EndSwitch _GUICtrlMenu_DestroyMenu($hMenu) EndFunc ;==>_Popup_Menu ; React on a button click Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam) #forceref $hWnd, $Msg Local $nNotifyCode = BitShift($wParam, 16) ;Local $nID = BitAND($wParam, 0x0000FFFF) Local $hCtrl = $lParam Local $sText = "" Switch $hCtrl Case $hButton_2 Switch $nNotifyCode Case $BN_CLICKED $sText = "Button 2 Clicked - " & _GUICtrlButton_GetText($hButton_2) EndSwitch EndSwitch If $sText <> "" Then ConsoleWrite($sText & @CRLF) Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMANDI will release a new version soon - keep your eyes open. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Tankbuster Posted August 2, 2013 Share Posted August 2, 2013 The buttons looks very interesting and space saving. Can't wait to see it in the UDF with "my" selectable file remover.....yes I still believe in fairies . Aren't those the little persons that code for you ? But it is ok. I could do it with the result. It does not ruin anything I created. So thx at least for thing about it. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 3, 2013 Author Moderators Share Posted August 3, 2013 New version 3 Aug 13Added:- 1. Passing a filename as the $sRoot parameter opens the tree in the folder containing the file with the file highlighted as the default selection. Thanks to jmon for the suggestion (even if he ignored the Beta I posted). -2. For multiple selections when using CFF_Choose there is now an "Add" and a "Delete" button which act on the selected item - double-clicking on a TreeView item will still add (or delete if Ctrl is pressed) the item. In CFF_EMBED double-clicking remains the only way to add or delete items. Thanks again to Tankbuster for the suggestion - even if this change does not go quite as far as he originally requested. New examples and UDF in the first post. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 4, 2013 Author Moderators Share Posted September 4, 2013 Hi,I have been working on a version of the UDF that makes sure that the files in an opened folder are visible if only files can be selected. It seemed logical to me to emphasise the files if they were the only thing selectable - several other apps I use do the same thing. Obviously this means that you have to scroll around a bit more if the file you want is deeper in the tree, but I think it is a price worth paying.Here is the modifed UDF and an example script: Any comments welcome. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 20, 2013 Author Moderators Share Posted September 20, 2013 (edited) Tankbuster, The "little fairy people" who code for me (see post #77 above) have been asked to realise your wish to be able to delete items directly from the "selected" list. So try this version and see if it meets with your approval: In "Choose" mode you add by double clicking a TreeView item or selecting an item and using the "Add" button - you delete by selecting the item in either the TreeView or the list and then pressing "Delete". In "Embed" mode you still need to doubleclick the item in the TreeView to add and doubleclick with Ctrl pressed to delete as the list is not part of the UDF. Good enough - or do you want even more? M23 P.S. Comments from anyone else welcome of course. Edited September 27, 2017 by Melba23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now