Hobbyist Posted October 31, 2014 Share Posted October 31, 2014 Have read the Help section, but still questioning.. _FilelistToArray If I use _FileListToArray to show a list of files (for example - CMy FilesMy Stuff), should I then be able to use _GUICtrlListView_AddArray to display the results in a ListView? For instance: (just including the script in question) $List4 = GUICtrlCreateListview("", 192, 72, 470, 260) ;create the ListView etc. to get the control displayed etc $aFileList = _FileListToArray("CMy Files|My Stuff" , "*") ;to get all the files in this directory _GUICtrlListView_AddArray($List4,$aFileList ) ;get results into ListView Should that add the whole array to the ListView? Or is a For/Next routine still needed, although it would seem to defeat the purpose of the previous command. I know I can get it done with a For/Next routine and using GUICtrlCreateListViewItem, but was just looking for any alternative as well. When I use _FileListToArray, I can get and display an array, so it appears to work there, but if I go further and add the script _GUICtrlListView_AddArray, it does not add the results to the ListView. Thanks Hobbyist Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 31, 2014 Moderators Share Posted October 31, 2014 Hobbyist,_GUICtrlListView_AddArray requires a 2D array while _FilelistToArray returns a 1D array - hence your problem. I would stick with a loop if I were you. 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...
jdelaney Posted October 31, 2014 Share Posted October 31, 2014 (edited) You can modify the functions (ctrl+j, while cursor is inside the function name)...you can make a local copy, like this, for 1 or 2d arrays: #include <File.au3> #include <GuiListView.au3> lOCAL $ARRAY = _FileListToArray(@DesktopDir) _ArrayDelete($ARRAY,0) ; Create GUI GUICreate("ListView Add Array", 400, 300) $hListView = GUICtrlCreateListView("", 2, 2, 394, 268) _GUICtrlListView_AddColumn($hListView, "Items", 100) GUISetState() ; Add columns _GUICtrlListView_AddArray_($hListView,$ARRAY) expandcollapse popupFunc _GUICtrlListView_AddArray_($hWnd, ByRef $aItems) If $Debug_LV Then __UDF_ValidateClassName($hWnd, $__LISTVIEWCONSTANT_ClassName) Local $fUnicode = _GUICtrlListView_GetUnicodeFormat($hWnd) Local $tItem = DllStructCreate($tagLVITEM) Local $tBuffer If $fUnicode Then $tBuffer = DllStructCreate("wchar Text[4096]") Else $tBuffer = DllStructCreate("char Text[4096]") EndIf DllStructSetData($tItem, "Mask", $LVIF_TEXT) DllStructSetData($tItem, "Text", DllStructGetPtr($tBuffer)) DllStructSetData($tItem, "TextMax", 4096) Local $iLastItem = _GUICtrlListView_GetItemCount($hWnd) _GUICtrlListView_BeginUpdate($hWnd) If IsHWnd($hWnd) Then If _WinAPI_InProcess($hWnd, $_lv_ghLastWnd) Then For $iI = 0 To UBound($aItems) - 1 DllStructSetData($tItem, "Item", $iI) DllStructSetData($tItem, "SubItem", 0) If UBound($aItems,0) = 1 Then DllStructSetData($tBuffer, "Text", $aItems[$iI]) Else DllStructSetData($tBuffer, "Text", $aItems[$iI][0]) EndIf _SendMessage($hWnd, $LVM_INSERTITEMW, 0, $tItem, 0, "wparam", "struct*") For $iJ = 1 To UBound($aItems, 2) - 1 DllStructSetData($tItem, "SubItem", $iJ) DllStructSetData($tBuffer, "Text", $aItems[$iI][$iJ]) _SendMessage($hWnd, $LVM_SETITEMW, 0, $tItem, 0, "wparam", "struct*") Next Next Else Local $iBuffer = DllStructGetSize($tBuffer) Local $iItem = DllStructGetSize($tItem) Local $tMemMap Local $pMemory = _MemInit($hWnd, $iItem + $iBuffer, $tMemMap) Local $pText = $pMemory + $iItem DllStructSetData($tItem, "Text", $pText) For $iI = 0 To UBound($aItems) - 1 DllStructSetData($tItem, "Item", $iI + $iLastItem) DllStructSetData($tItem, "SubItem", 0) If UBound($aItems,0) = 1 Then DllStructSetData($tBuffer, "Text", $aItems[$iI]) Else DllStructSetData($tBuffer, "Text", $aItems[$iI][0]) EndIf _MemWrite($tMemMap, $tItem, $pMemory, $iItem) _MemWrite($tMemMap, $tBuffer, $pText, $iBuffer) If $fUnicode Then _SendMessage($hWnd, $LVM_INSERTITEMW, 0, $pMemory, 0, "wparam", "ptr") Else _SendMessage($hWnd, $LVM_INSERTITEMA, 0, $pMemory, 0, "wparam", "ptr") EndIf For $iJ = 1 To UBound($aItems, 2) - 1 DllStructSetData($tItem, "SubItem", $iJ) DllStructSetData($tBuffer, "Text", $aItems[$iI][$iJ]) _MemWrite($tMemMap, $tItem, $pMemory, $iItem) _MemWrite($tMemMap, $tBuffer, $pText, $iBuffer) If $fUnicode Then _SendMessage($hWnd, $LVM_SETITEMW, 0, $pMemory, 0, "wparam", "ptr") Else _SendMessage($hWnd, $LVM_SETITEMA, 0, $pMemory, 0, "wparam", "ptr") EndIf Next Next _MemFree($tMemMap) EndIf Else Local $pItem = DllStructGetPtr($tItem) For $iI = 0 To UBound($aItems) - 1 DllStructSetData($tItem, "Item", $iI + $iLastItem) DllStructSetData($tItem, "SubItem", 0) If UBound($aItems,0) = 1 Then DllStructSetData($tBuffer, "Text", $aItems[$iI]) Else DllStructSetData($tBuffer, "Text", $aItems[$iI][0]) EndIf If $fUnicode Then GUICtrlSendMsg($hWnd, $LVM_INSERTITEMW, 0, $pItem) Else GUICtrlSendMsg($hWnd, $LVM_INSERTITEMA, 0, $pItem) EndIf For $iJ = 1 To UBound($aItems, 2) - 1 DllStructSetData($tItem, "SubItem", $iJ) DllStructSetData($tBuffer, "Text", $aItems[$iI][$iJ]) If $fUnicode Then GUICtrlSendMsg($hWnd, $LVM_SETITEMW, 0, $pItem) Else GUICtrlSendMsg($hWnd, $LVM_SETITEMA, 0, $pItem) EndIf Next Next EndIf _GUICtrlListView_EndUpdate($hWnd) EndFunc ;==>_GUICtrlListView_AddArray Edited October 31, 2014 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 31, 2014 Moderators Share Posted October 31, 2014 jdelaney,Thanks for posting that. I will look into modifying the function over the weekend. 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...
jdelaney Posted October 31, 2014 Share Posted October 31, 2014 (edited) Not that it breaks anything, but the second loop might as well be in their respective else statments . Kind of defeats the purpose of a list anyways...probably should just use a listbox. Edited October 31, 2014 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
Hobbyist Posted October 31, 2014 Author Share Posted October 31, 2014 You folks are excellent! This is such value added from my perspective, so thanks much for taking time to answer. Hobbyist 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