Wb-FreeKill Posted April 12, 2005 Share Posted April 12, 2005 I was given this eksample of how to retrieve what the listviewitem contained.. and it work just fine. But how can i get something specific from the listviewitem, like: GuiCtrlCreateListViewItem("GUI1item1|GUI1item2|GUI1item3",$listviewGUI1) Get GUI1item2, if use this eksample below, it will only retrieve the first "item" in the listviewitem.. so how can i get the 2'end, and the 3'rd, ir the whole listviewitem #include <GUIConstants.au3> $GUI_1 = GUICreate("listview items",220,250, 0,0,-1) $listviewGUI1 = GuiCtrlCreateListView ("col1 |col2 |col3 ",10,10,200,150);,$LVS_SORTDESCENDING) $button1 = GuiCtrlCreateButton ("GUI1GetSelected",10,170,100,20) $button2 = GuiCtrlCreateButton ("GUI2GetSelected",110,170,100,20) GuiCtrlCreateListViewItem("GUI1item1|GUI1item2|GUI1item3",$listviewGUI1) GuiSetState() $GUI_2 = GUICreate("listview items",220,250, 300,0,-1) $listviewGUI2 = GuiCtrlCreateListView ("col1 |col2 |col3 ",10,10,200,150);,$LVS_SORTDESCENDING) GuiCtrlCreateListViewItem("GUI2item1|GUI2item2|GUI2item3",$listviewGUI2) GuiSetState() Do $msg = GuiGetMsg () Select Case $msg = $button1 If ControlListView ( $GUI_1, "", "SysListView321","GetSelectedCount") > 0 Then MsgBox(0,"",ControlListView ( $GUI_1, "", "SysListView321","GetText", ControlListView ( $GUI_1, "", "SysListView321","GetSelected"))) EndIf Case $msg = $button2 If ControlListView ( $GUI_2, "", "SysListView321","GetSelectedCount") > 0 Then MsgBox(0,"",ControlListView ( $GUI_2, "", "SysListView321","GetText", ControlListView ( $GUI_2, "", "SysListView321","GetSelected"))) EndIf EndSelect Until $msg = $GUI_EVENT_CLOSE Link to comment Share on other sites More sharing options...
jpm Posted April 12, 2005 Share Posted April 12, 2005 If you are using GUI functions. You will use $item=GuiCtrlRead($idItem) to read a specific item and you will get the different element by $splitItem=$StringSplit($item, "|") the "GUI1item2" will be $splitItem[2] You can certainly use ControlListView to retrieve a specific element but I confess I design GUI function to be self sufficient. It is true that using other non GUI function can work but I confess I want to help using GUI functions first. Link to comment Share on other sites More sharing options...
Wb-FreeKill Posted April 12, 2005 Author Share Posted April 12, 2005 Sound quite easy, but i dont understand the GUICtrlRead.. Just tried, and it didn't work.. didn't expect it so eiter.. If $msg = $TryButton Then $item = GuiCtrlRead(ControlListView ($ClientQueueGUI, "", "SysListView321","GetText", ControlListView ($ClientQueueGUI, "", "SysListView321","GetSelected")))) $splitItem=$StringSplit($item, "|") ;If ControlListView ($ClientQueueGUI, "", "SysListView321","GetSelectedCount") > 0 Then MsgBox(0,"",$splitItem[2] ;EndIf EndIf what do i have to GUICtrlRead? Link to comment Share on other sites More sharing options...
jpm Posted April 12, 2005 Share Posted April 12, 2005 Sound quite easy, but i dont understand the GUICtrlRead..Just tried, and it didn't work.. didn't expect it so eiter..If $msg = $TryButton Then $item = GuiCtrlRead(ControlListView ($ClientQueueGUI, "", "SysListView321","GetText", ControlListView ($ClientQueueGUI, "", "SysListView321","GetSelected")))) $splitItem=$StringSplit($item, "|") ;If ControlListView ($ClientQueueGUI, "", "SysListView321","GetSelectedCount") > 0 Then MsgBox(0,"",$splitItem[2] ;EndIf EndIfwhat do i have to GUICtrlRead?<{POST_SNAPBACK}>Just read the GUICtrlCreateListViewItem example it will be more clear than my previous post (I hope) Link to comment Share on other sites More sharing options...
Michael.Curley Posted April 14, 2005 Share Posted April 14, 2005 Per the help....ListView Control identifier (controlID) of the selected ListViewItem. 0 means no item is selectedPersonally, I am trying to make some udfs to make this all easier. But it requires a bit if discipline if you want to do anything more than "display".You can see the code I am currently using to create a listview from a 2 dimensional array at this post.Later you can tell what "row" in the data array is selected by examining the handles.Func lsv_files_btn_delete() GuiCtrlDeleteListViewArrayItem ($array_hand, $array_Data) EndFunc ;==>lsv_files_btn_deleteFunc GuiCtrlDeleteListViewArrayItem(ByRef $CtrlArray, ByRef $DataArray) Local $i Local $SelectedItem = 0 Local $CtrlRead = GuiCtrlRead($CtrlArray[0]) For $i = 1 to Ubound($CtrlArray) -1 If $CtrlArray[$i] = $CtrlRead Then $SelectedItem = $i MsgBox(0,"Selected Item", "$i = " & $i) ;ExitLoop EndIf Next IF $SelectedItem = 0 Then Seterror(-1) Return EndIf GUICtrlDelete($CtrlArray[$SelectedItem]) _ArrayDelete($CtrlArray, $SelectedItem ) ArrayDelete2Dim($DataArray, $SelectedItem ) EndFuncFunc ArrayDelete2Dim(ByRef $ArrayIn, $RowDelete) Local $Ubound1 = UBound($ArrayIn, 1) If $RowDelete > $Ubound1 Then Return Local $Ubound2 = UBound($ArrayIn, 2) Local $Return[$Ubound1 - 1][$Ubound2] Local $i Local $j For $i = 0 To $Ubound1 - 1 For $j = 0 To $Ubound2 - 1 If $i < $RowDelete Then $Return[$i][$j] = $ArrayIn[$i][$j] If $i > $RowDelete Then $Return[$i - 1][$j] = $ArrayIn[$i][$j] Next Next $ArrayIn = $Return Return EndFunc ;==>ArrayDelete2DimIts not exactly simple... at this point. I am going to try and clean it up and once I have all of the code for the rest of the things I want to be able to do, I will post the whole collection of UDFs tot he scrips and scraps forum for review/addition to standard library. For this task I also created a MultiDimArrayToIni() and a IniToMultiDimArray() func for storing/retrieving all of this information, that I posted to the mailing list group on yahoo. They work for up to 8 dimensional arrays, tho I have no idea what anyone would want an 8 dim array for.. Link to comment Share on other sites More sharing options...
steveR Posted April 14, 2005 Share Posted April 14, 2005 (edited) so how can i get the 2'end, and the 3'rd, ir the whole listviewitemLike this:Do $msg = GuiGetMsg () Select Case $msg = $button1 $item = GUICtrlRead(GUICtrlRead($listviewGUI1)) if $item then MsgBox(0,"",$item, 1) $item = StringSplit($item, "|") MsgBox(0,"",$item[1], 1) MsgBox(0,"",$item[2], 1) MsgBox(0,"",$item[3], 1) EndIf EndSelect Until $msg = $GUI_EVENT_CLOSE Edited April 14, 2005 by steveR AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass. Link to comment Share on other sites More sharing options...
GaryFrost Posted April 14, 2005 Share Posted April 14, 2005 (edited) lots of ways to skin a cat when it comes to listviews expandcollapse popup#include <GUIConstants.au3> $GUI_WIN = GUICreate("My GUI listview test",300,200) $listview = GUICtrlCreateListView ("col1 |col2|col3 ",10,10,200,150);,$LVS_SORTDESCENDING) $item1=GUICtrlCreateListViewItem("item1|col2-1|col3-1",$listview) $item2=GUICtrlCreateListViewItem("item2|col2-2|col3-2",$listview) GUISetState () Dim $DIFF, $START,$DOUBLECLICKED,$MOUSESPEED,$index ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() select Case $msg = ($GUI_EVENT_PRIMARYDOWN) Dim $FOCUS = ControlGetFocus($GUI_WIN) If ($FOCUS == "SysListView321") Then $DIFF = TimerDiff($START) ; Read the current mouse-doubleclick-settings from registry $MOUSESPEED = RegRead("HKCU\Control Panel\Mouse","DoubleClickSpeed") If $MOUSESPEED = "" Then $MOUSESPEED = 500 If ($DIFF < $MOUSESPEED And $DOUBLECLICKED == 0) Then $ITEMCLICKED = GUICtrlRead($listview) If ($ITEMCLICKED > 0) Then MsgBox(0,"Test1",GUICtrlRead(GUICtrlRead($listview))) MsgBox(0,"test2",_GUICtrlLVGetItemText($listview, $GUI_WIN)) Dim $a_items = _GUICtrlLVGetItemsText($listview) MsgBox(0,"test3",$a_items[1] & @CRLF & $a_items[2]& @CRLF & $a_items[3]) MsgBox(0,"test4",_GUICtrlLVGetItemText($listview, $GUI_WIN,"",-1,0) & @CRLF & _ _GUICtrlLVGetItemText($listview, $GUI_WIN,"",-1,1) & @CRLF & _ _GUICtrlLVGetItemText($listview, $GUI_WIN,"",-1,2)) $index = _GUICtrlListViewIndexSelected($listview,$GUI_WIN) MsgBox(0,"test5",_GUICtrlLVGetItemText($listview, $GUI_WIN,"",$index)) MsgBox(0,"test6",_GUICtrlLVGetItemText($listview, $GUI_WIN,"",$index,0) & @CRLF & _ _GUICtrlLVGetItemText($listview, $GUI_WIN,"",$index,1) & @CRLF & _ _GUICtrlLVGetItemText($listview, $GUI_WIN,"",$index,2)) EndIf $DOUBLECLICKED = 1 Else $DOUBLECLICKED = 0 EndIf $START = TimerInit() EndIf EndSelect If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend Func _GUICtrlLVGetItemText($lv, $WindowTitle, $WindowText="",$Item=-1,$SubItem=-1) Local $X,$count,$str $count = ControlListView ( $WindowTitle, $WindowText, $lv, "GetSubItemCount") if(ControlListView ( $WindowTitle, $WindowText, $lv, "GetSelectedCount")) Then If($SubItem == -1) Then; return all the subitems in the item selected For $X=0 To $count - 1 Step 1 If($str) Then If($Item == -1) Then $str = $str & "|" & ControlListView ( $WindowTitle, $WindowText, $lv, "GetText", ControlListView ( $WindowTitle, $WindowText, $lv, "GetSelected"), $X ) Else $str = $str & "|" & ControlListView ( $WindowTitle, $WindowText, $lv, "GetText", $Item, $X ) EndIf Else If($Item == -1) Then $str = ControlListView ( $WindowTitle, $WindowText, $lv, "GetText", ControlListView ( $WindowTitle, $WindowText, $lv, "GetSelected"), $X ) Else $str = ControlListView ( $WindowTitle, $WindowText, $lv, "GetText", $Item, $X ) EndIf EndIf Next Return $str ElseIf($SubItem < $count) Then; return the subitem in the item selected If($Item == -1) Then Return ControlListView ( $WindowTitle, $WindowText, $lv, "GetText", ControlListView ( $WindowTitle, $WindowText, $lv, "GetSelected"), $SubItem ) Else Return ControlListView ( $WindowTitle, $WindowText, $lv, "GetText", $Item, $SubItem ) EndIf Else ; set an error, subitem is out of range SetError( -1 ) Return @error EndIf Else ; set an error, no item selected SetError( -2 ) Return @error EndIf EndFunc Func _GUICtrlLVGetItemsText($lv) Return StringSplit(GUICtrlRead(GUICtrlRead($lv)),"|") EndFunc Func _GUICtrlListViewIndexSelected($lv,$WindowTitle,$WindowText="") Return ControlListView($WindowTitle,$WindowText,$lv,"FindItem", ControlListView ( $WindowTitle, $WindowText, $lv, "GetText", ControlListView ( $WindowTitle, $WindowText, $lv, "GetSelected"), 0 )) EndFunc Edit: added another way. Edited April 15, 2005 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
bshoenhair Posted April 15, 2005 Share Posted April 15, 2005 @gafrost Just an observation. Your doubleclick doesn't function correctly if your intention is to return values based on doubleclicking on the listview. Try this, select an item in the listview, move mouse so it is not over the listview but still on GUI and double click, it should not return the values since you are not on the listview but it does. Link to comment Share on other sites More sharing options...
GaryFrost Posted April 15, 2005 Share Posted April 15, 2005 that's the one of the drawbacks of using the primarydown. what is needed is a click/doubleclick event on the listview, none at this time that doubleclick was some script that given by another forum user. SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
bshoenhair Posted April 17, 2005 Share Posted April 17, 2005 that's the one of the drawbacks of using the primarydown.what is needed is a click/doubleclick event on the listview, none at this timethat doubleclick was some script that given by another forum user.<{POST_SNAPBACK}>GUIGetCursorInfo() should do the trick, right ? Link to comment Share on other sites More sharing options...
GaryFrost Posted April 17, 2005 Share Posted April 17, 2005 (edited) Yep, thinking that would do the trick. At least the one that's in the current beta anyways. change old code from above example From: Dim $FOCUS = ControlGetFocus($GUI_WIN) If ($FOCUS == "SysListView321") Then To: Dim $MousePos = GUIGetCursorInfo() If ($MousePos[4] == $listview) Then and it works correctly Edited April 17, 2005 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. 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