;********** ;ListView UDFs ;********** Func _GUICtrlGetListViewColsCount(ByRef $lv,$title="",$text="") If(StringLen($title)==0) Then $title = WinGetTitle("") EndIf Return ControlListView($title ,$text, $lv, "GetSubItemCount") EndFunc Func _GUICtrlGetListViewItemsCount(ByRef $lv,$title="",$text="") If(StringLen($title)==0) Then $title = WinGetTitle("") EndIf Return ControlListView($title ,$text, $lv, "GetItemCount") EndFunc Func _GUICtrlLVClear($listview) ; Removes all items from a list-view control. Local $LVM_DELETEALLITEMS = 0x1009 ; Returns TRUE if successful, or FALSE otherwise. Return GuiCtrlSendMsg($listview, $LVM_DELETEALLITEMS,0,0) EndFunc Func _GUICtrlLVGetItemsText($lv) ; returns an array of the subitems from an item Return StringSplit(GUICtrlRead(GUICtrlRead($lv)),"|") EndFunc ;=============================================================================== ; Function: _GUICtrlLVGetItemText ; Author: Gary Frost ; ; Description: Get the text if the item (all or 1 subitem) ; Parameters: $lv - The ListView Control to get the text from ; $WindowTitle - The Title to the window the control resides on ; [$WindowText] - The Text from the window the control resides on ; [$Item] - The Item to get data from ; [$SubItem] - The SubItem to get the text from ; Requirements: None ; Return Values: Text from item/subitem(s) or error ; ; Note: None ;=============================================================================== 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 ;=============================================================================== ; ; Description: _GUICtrlLVDeleteItems ; Parameter(s): $lv - listview control id ; $WindowTitle - Text or gui id ; [$WindowText]- Text on Window ; Requirement: None ; Return Value(s): None ; User CallTip: None ; Author(s): Gary Frost