Modify

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#3753 closed Bug (Completed)

_GUICtrlListView_SetImageList does not check for errors

Reported by: MrCreatoR Owned by: Melba23
Milestone: 3.3.15.1 Component: AutoIt
Version: 3.3.14.5 Severity: None
Keywords: Cc:

Description

Example:

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>

Example()

Func Example()
    Local $hImage, $idListview

    GUICreate("ListView Set Image List", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)
	
    ; Load images
    $hImage = _GUIImageList_Create()
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0xFF0000, 16, 16))
    _GUICtrlListView_SetImageList($idListview, $hImage, -1)
	
    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

If third parameter ($iType) passed as not supported type (< 0 Or > 2) the script crashes.

GuiListView.au3 (3809) : ==> Variable subscript badly formatted.:
Return Ptr(GUICtrlSendMsg($hWnd, $LVM_SETIMAGELIST, $aType[$iType], $hHandle))
Return Ptr(GUICtrlSendMsg($hWnd, $LVM_SETIMAGELIST, $aType[^ ERROR

I know it's wrong usage, but still should be some error checking in _GUICtrlListView_SetImageList function:

Func _GUICtrlListView_SetImageList($hWnd, $hHandle, $iType = 0)
	$iType = Int($iType) ;In case the $iType passed as other var type than int
	
	If $iType < 0 Or $iType > 2 Then
		Return SetError(1, 0, 0)
		;Or ommit the Return and set:
		$iType = 0
	EndIf
	
	Local $aType[3] = [$LVSIL_NORMAL, $LVSIL_SMALL, $LVSIL_STATE]
	
	If IsHWnd($hWnd) Then
		Return _SendMessage($hWnd, $LVM_SETIMAGELIST, $aType[$iType], $hHandle, 0, "wparam", "handle", "handle")
	Else
		Return Ptr(GUICtrlSendMsg($hWnd, $LVM_SETIMAGELIST, $aType[$iType], $hHandle))
	EndIf
EndFunc

Attachments (0)

Change History (3)

comment:1 Changed 4 years ago by Melba23

  • Milestone set to 3.3.15.1
  • Owner set to Melba23
  • Resolution set to Completed
  • Status changed from new to closed

Added by revision [12254] in version: 3.3.15.1

comment:2 Changed 4 years ago by Melba23

Added by revision [12255] in version: 3.3.15.1

comment:3 Changed 4 years ago by Melba23

I went with the "set to 0" suggestion.

M23

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 Melba23.
Author


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

 
Note: See TracTickets for help on using tickets.