cappy2112 Posted November 19, 2016 Posted November 19, 2016 (edited) Previous reply In the URL above, JLogan3013 posted some code to create a listview. This has been quite helpful. I've been trying to add a second column into the ListView, so that I can provide a mechanism for the user to paste in a path, for each of the items in the first column. See the attached screenshot of what I'm trying to do- using AutoIt. Column0 is contains a list of Windows found by WinList() Column1 will contain a path- that the user provides. I've been going back and forth between _GUICtrlListView_AddSubItem(), _GUICtrlListView_InsertColumn, and _GUICtrlListView_AddSubItem(), trying to get a second column, but it's not going well. The examples I've been reading in the AutoIt help file for those APIs (and others) did not do what I was expecting. My code is now a mess of comments, but it started as a working a example from JLogan3013. Which function should I use to add the second column? expandcollapse popupFunc ShowListView($WindowList) Const $Centered = -1 Local $aList, $hGUI Local $HWinSize = 900 Local $VWinSize = 600 Local $ListboxColWidth Local $i Local $WindowCount If IsArray($WindowList) Then $hGUI = GUICreate("Window Instances", 900, 300, $Centered, $Centered) $ListboxColWidth = $HWinSize - 20 $hListView = GUICtrlCreateListView("", 10, 10, $ListboxColWidth, 200) _GUICtrlListView_SetColumnWidth($hListView, 1, $ListboxColWidth) ;_GUICtrlListView_InsertColumn($hListView, 2, "Column 1", 100) $btnDone = GUICtrlCreateButton("DONE", ($HWinSize / 2) - 20, 235, 55, 45) $WindowCount = $WindowList[0][0] GUICtrlCreateListViewItem($WindowList[1][0], $hListView) For $i = 1 To $WindowCount ;GUICtrlCreateListViewItem($hListView, $WindowList[$i][0],) _GUICtrlListView_AddItem($hListView, $WindowList[$i][0], $i) ;_GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0) ;_GUICtrlListView_AddSubItem($hListView, 0, "Z:\NetworkPath\Hawk5\KVM1", $i) Next If ($WindowCount > 1) Then EndIf GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") GUISetState(@SW_SHOW) While 1 $aTemp = _GUICtrlListView_GetItemTextArray($hListView) Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $btnDone If ($aTemp[0] = 0) Then _ArrayDisplay($aTemp) MsgBox($MB_OK, "", "Please select a window first") Else _ArrayDisplay($aTemp) MsgBox($MB_OK, "", "You selected " & $aTemp[1]) EndIf EndSwitch WEnd GUIDelete() Else MsgBox($MB_ICONWARNING, "IsArray()", "LIST VIEW is not an array") EndIf EndFunc ;==>ShowListView Func _WM_NOTIFY($nWnd, $iMsg = "", $wParam = "", $lParam = "") Local $tStruct = DllStructCreate("hwnd;uint_ptr;int_ptr;int;int", $lParam) If BitAND(DllStructGetData($tStruct, 3), 0xFFFFFFFF) = $NM_CLICK Then ; Code $hCurrListView = DllStructGetData($tStruct, 1) ; ListView handle EndIf EndFunc ;==>_WM_NOTIFY Edited November 19, 2016 by cappy2112
kylomas Posted November 19, 2016 Posted November 19, 2016 cappy2112, Example of adding and populating two columns to a listview. #include <array.au3> #include <GuiListView.au3> #include <WinAPIProc.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> local $aWinlist = winlist() ;_arraydisplay($aWinlist) local $gui010 = guicreate('Windows / Paths', 600, 400) local $lv010 = guictrlcreatelistview('',10,10,580,380) _GUICtrlListView_AddColumn($lv010, "Window Title", 250) _GUICtrlListView_AddColumn($lv010, "Path to Program", 300) for $i = 1 to $aWinlist[0][0] if $aWinlist[$i][0] <> '' And BitAND(WinGetState($aWinlist[$i][1]), 2) then GUICtrlCreateListViewItem($aWinlist[$i][0] & '|' & _WinAPI_GetProcessFileName(wingetprocess($aWinlist[$i][1])), $lv010) Next guisetstate() Local $msg While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd kylomas You will get better help if you give us as much detail as possible. Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill
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