Damein Posted July 13, 2014 Share Posted July 13, 2014 (edited) Alright, so I have this as an example: #include <GUIConstantsEx.au3> #include <GuiListView.au3> Opt("GUIOnEventMode", 1) $Gui = GuiCreate("Test", 400,500) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") $TreeView = GUICtrlCreateTreeView(10, 10, 100, 300) $TreeViewItem = GUICtrlCreateTreeViewItem("Test", $TreeView) $TreeViewItemSub = GUICtrlCreateTreeViewItem("Sub Test", $TreeViewItem) $ListView = GUICtrlCreateListView("List", 160, 10, 200, 200) _GUICtrlListView_AddItem($ListView, "TestItem") _GUICtrlListView_AddItem($ListView, "TestItem2") _GUICtrlListView_AddItem($ListView, "TestItem3") GuiCtrlCreateButton("Read", 20, 400) GUICtrlSetOnEvent(-1, "_Read") GuiSetState() Func _Read() $Index = ControlListView($Gui, "Test", $ListView,"GetSelected") $txt = _GUICtrlListView_GetItemText($ListView, $Index) MsgBox(0, "Test", "Index: " & $Index & @CRLF & "Data: " & $txt) EndFunc Func _Exit() Exit EndFunc While 1 Sleep(10) WEnd Now the MsgBox for $index shows the correct number but the MsgBox for $txt is blank. But if I manually set $Index = 1 the MsgBox for $txt show's the data for that item... Can the GetItemText not use a variable for it's count or am I doing something wrong here? Thanks! Edited July 13, 2014 by Damein Most recent sig. I made Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 13, 2014 Moderators Share Posted July 13, 2014 Damein,You are creating the ListView using the native function and adding the items using the UDF function - a sure recipe for tears. As a result, you are not getting the correct value for ControlId/handle to use with _GUICtrlListView_GetItemText. Best to stick with the native functions like this:#include <GUIConstantsEx.au3> #include <GuiListView.au3> Opt("GUIOnEventMode", 1) $Gui = GUICreate("Test", 400, 500) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") $TreeView = GUICtrlCreateTreeView(10, 10, 100, 300) $TreeViewItem = GUICtrlCreateTreeViewItem("Test", $TreeView) $TreeViewItemSub = GUICtrlCreateTreeViewItem("Sub Test", $TreeViewItem) $ListView = GUICtrlCreateListView("List ", 160, 10, 200, 200) GUICtrlCreateListViewItem("TestItem1", $ListView) GUICtrlCreateListViewItem("TestItem2", $ListView) GUICtrlCreateListViewItem("TestItem3", $ListView) GUICtrlCreateButton("Read", 20, 400) GUICtrlSetOnEvent(-1, "_Read") GUISetState() Func _Read() $txt = StringTrimRight(GUICtrlRead(GUICtrlRead($ListView)), 1) MsgBox(0, "Test", "Data: " & $txt) EndFunc ;==>_Read Func _Exit() Exit EndFunc ;==>_Exit While 1 Sleep(10) WEndAll clear? 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...
careca Posted July 13, 2014 Share Posted July 13, 2014 (edited) Dunno, doesn't work here either, but when i change $Index = ControlListView($Gui, "Test", $ListView,"GetSelected") For $Index = _GUICtrlListView_GetNextItem($ListView, -1, 0, 8) It works, so there must be a problem with $Index = ControlListView($Gui, "Test", $ListView,"GetSelected"), parameters seem correct.. EDIT: arrived too late Edited July 13, 2014 by careca Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
Damein Posted July 13, 2014 Author Share Posted July 13, 2014 I'll look over your stuff Melba but I thought I'd post what I tried randomly and got to work.. which I don't think should of worked! Lol! Seem's to be a weird bug, obviously it has problems with a variable being used if no number is presented so I tried this and viola it works perfectly. $Text = _GUICtrlListView_GetItemText($ListView, 0+$Index) So in full: #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <GuiListView.au3> Opt("GUIOnEventMode", 1) $Gui = GuiCreate("Test", 400,500) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") $TreeView = GUICtrlCreateTreeView(10, 10, 100, 300) $TreeViewItem = GUICtrlCreateTreeViewItem("Test", $TreeView) $TreeViewItemSub = GUICtrlCreateTreeViewItem("Sub Test", $TreeViewItem) $ListView = GUICtrlCreateListView("List", 160, 10, 200, 200) _GUICtrlListView_AddItem($ListView, "TestItem") _GUICtrlListView_AddItem($ListView, "TestItem2") _GUICtrlListView_AddItem($ListView, "TestItem3") GuiCtrlCreateButton("Read", 20, 400) GUICtrlSetOnEvent(-1, "_Read") GuiSetState() Func _Read() $Index = ControlListView($Gui, "Test", $ListView,"GetSelected") $Text = _GUICtrlListView_GetItemText($ListView, 0+$Index) MsgBox(0, "Test", "Index: " & $Index & @CRLF & "Data: " & $Text) EndFunc Func _Exit() Exit EndFunc While 1 Sleep(10) WEnd Most recent sig. I made Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic Link to comment Share on other sites More sharing options...
mikell Posted July 13, 2014 Share Posted July 13, 2014 (edited) Beginning with ControlListview why didn't you continue ? $txt = ControlListView($Gui, "Test", $ListView,"GetText", $Index) Edit BTW the helpfile is clear about ControlListview(.... , "GetSelected") : "Returns a string containing the item index of selected items" so this works $txt = _GUICtrlListView_GetItemText($ListView, Number($Index)) Edited July 13, 2014 by mikell careca 1 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