Modify

Opened 10 years ago

Closed 10 years ago

#1326 closed Bug (No Bug)

_GuiCtrlListView_DeleteItem does not handle control ID correctly

Reported by: martin Owned by: Gary
Milestone: Component: Standard UDFs
Version: 3.3.0.0 Severity: None
Keywords: _GUICtrlListView_DeleteItem Cc:

Description

_GuiCtrlListView_DeleteItem works if the listview handle is passed but not if the control ID is passed.
The existing function is

; #FUNCTION# ====================================================================================================================
; Name...........: _GUICtrlListView_DeleteItem
; Description ...: Removes an item from a list-view control
; Syntax.........: _GUICtrlListView_DeleteItem($hWnd, $iIndex)
; Parameters ....: $hWnd        - Control ID/Handle to the control
;                  $iIndex      - Zero based index of the list-view item to delete
; Return values .: Success      - True
;                  Failure      - False
; Author ........: Gary Frost (gafrost)
; Modified.......:
; Remarks .......:
; Related .......: _GUICtrlListView_DeleteAllItems, _GUICtrlListView_DeleteItemsSelected
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _GUICtrlListView_DeleteItem($hWnd, $iIndex)
	If $Debug_LV Then __UDF_ValidateClassName($hWnd, $__LISTVIEWCONSTANT_ClassName)

	If IsHWnd($hWnd) Then
		Return _SendMessage($hWnd, $LVM_DELETEITEM, $iIndex) <> 0
	Else
		Local $ctrlID = _GUICtrlListView_GetItemParam($hWnd, $iIndex)
		If $ctrlID Then Return GUICtrlDelete($ctrlID) <> 0
	EndIf
	Return False
EndFunc   ;==>_GUICtrlListView_DeleteItem

This could be

Func _GUICtrlListView_DeleteItem($hWnd, $iIndex)
	If $Debug_LV Then __UDF_ValidateClassName($hWnd, $__LISTVIEWCONSTANT_ClassName)

	If IsHWnd($hWnd) Then
		Return _SendMessage($hWnd, $LVM_DELETEITEM, $iIndex) <> 0
	Else
	 Return GuiCtrlSendMsg($hWnd, $LVM_DELETEITEM, $iIndex,0)  <> 0
	EndIf
EndFunc   ;==>_GUICtrlListView_DeleteItem

Attachments (0)

Change History (1)

comment:1 Changed 10 years ago by Valik

  • Resolution set to No Bug
  • Status changed from new to closed

You should never destroy something AutoIt created with anything other than the specified function for destruction. To that end the Example2() in the documentation is actually doing something bad. Likewise, your suggestion is doing something bad. AutoIt will never free the internal resources for any items destroyed that way.

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The owner will remain Gary.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.