qwert Posted February 6, 2017 Share Posted February 6, 2017 I don't work with arrays all that often, so please excuse my asking what might be a basic question. Based on a "root filename", I use the _FileListToArrayRec to locate possible sources of a useful graphic ... which often has several file choices, as shown by the example below. I can envision a couple of ways to prompt the user (with a dialog) to make a selection, based on found files. But is there a direct way to know the row the user has clicked on? Thanks in advance for any help. Link to comment Share on other sites More sharing options...
iamtheky Posted February 6, 2017 Share Posted February 6, 2017 (edited) make your own listview (as I don't think you can do anything with _arraydisplay's listview) and hunt things about selecting its rows? Edited February 6, 2017 by iamtheky ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
Subz Posted February 6, 2017 Share Posted February 6, 2017 Alternatively you could use a ComboBox for example: expandcollapse popup#include <Array.au3> #include <ComboConstants.au3> #include <File.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Example() Func Example() Local $sFolderPath = @ScriptDir Local $aFolderPath = _FileListToArrayRec($sFolderPath, '*.ai;*.eps;*.jpg;*.gif;*.png', 1, 1, 0, 1) ; Create a GUI with various controls. Local $hGUI = GUICreate("Example", 300, 200) ; Create a combobox control. Local $idComboBox = GUICtrlCreateCombo("Please Select an Image", 10, 10, 185, 20, $CBS_DROPDOWNLIST) Local $idSelect = GUICtrlCreateButton("Select", 200, 9, 90, 23) Local $idClose = GUICtrlCreateButton("Close", 210, 170, 85, 25) ; Add additional items to the combobox. GUICtrlSetData($idComboBox, _ArrayToString($aFolderPath, '|', 1)) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) Local $sComboRead = "" ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idClose ExitLoop Case $idSelect If FileExists($sFolderPath & '\' & GUICtrlRead($idComboBox)) Then ShellExecute($sFolderPath & '\' & GUICtrlRead($idComboBox)) EndIf EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) EndFunc ;==>Example Link to comment Share on other sites More sharing options...
qwert Posted February 6, 2017 Author Share Posted February 6, 2017 Well, after what I can only describe as a learning experience, I opted to use AddItem. (AddArray turned into a confusing exercise of trying to use the indices right in the arrays.) The following statements worked ... and I ended up with a very sensible, scrollable panel of found files. If IsArray($array) Then For $i = 1 to $array[0] Step 1 _GUICtrlListView_AddItem($ListView, $array[$i]) Next EndIf The combo box method will be a handy alternative. Thanks for both responses. Link to comment Share on other sites More sharing options...
LarsJ Posted February 11, 2017 Share Posted February 11, 2017 From the Help file about _ArrayDisplay: Run User Func Run the user-defined function passed in $hUser_Function. This function is entirely separate from the UDF and must be created and coded by the user to accept 2 (and only 2) parameters which will be provided by the UDF itself: the full array being displayed and a 1D array holding the selected rows indices with a count in the [0] element. These parameters can then be used inside the user function as required. The button is not displayed if no function is specified. And the code: #include <Array.au3> Global $aSelRows Global $aArray[10][6] For $i = 0 To 9 For $j = 0 To 5 $aArray[$i][$j] = $i & "/" & $j Next Next _ArrayDisplay( $aArray, "Select one/more items. Click ""Run User Func""", "", 0, Default, Default, Default, Default, GetSelected ) Func GetSelected( $aArray, $aSelected ) $aSelRows = $aSelected If $aSelRows[0] = 0 Then MsgBox( 0, "", "Select one/more items. Click ""Run User Func""" ) Else MsgBox( 0, "", $aSelRows[0] & " items selected" ) Send( "{ESC}" ) EndIf EndFunc _ArrayDisplay( $aSelRows ) iamtheky, spudw2k and Jfish 3 Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
qwert Posted February 15, 2017 Author Share Posted February 15, 2017 @LarsJ: Thanks for reminding me of that method. I recall using something similar 4 or 5 years ago. I'm sure it will come in handy, again. But for now, I'm firmly on the ListView track for this project ... and learning more every day. 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