Opened 12 years ago

Closed 12 years ago

Last modified 11 years ago

#249 closed Bug (Fixed)

_WinAPI_UpdateLayeredWindow() - missing error checking

Reported by: Zedna Owned by: Gary
Milestone: Component: Standard UDFs
Version: Severity: None
Keywords: Cc:


in WinApi.au3 include file in _WinAPI_UpdateLayeredWindow() is missing error checking.

UpdateLayeredWindow API doesn't exists on WIN9x Windows (only WIN 2000 and above) so if you call this UDF function on WIN9x it crashes with this error:

==> Subscript used with non-Array variable.: 
Return SetError($aResult[0] = 0, 0, $aResult[0] <> 0) 
Return SetError($aResult^ ERROR

After DllCall() should be added this:

If @error Then Return SetError(1, 0, 0)

Here is complete testing script
with original commented UDF and corrected one:

_WinAPI_UpdateLayeredWindow(0, 0, 0, 0, 0, 0, 0, 0, 0)

;~ Func _WinAPI_UpdateLayeredWindow($hWnd, $hDCDest, $pPTDest, $pSize, $hDCSrce, $pPTSrce, $iRGB, $pBlend, $iFlags)
;~ 	Local $aResult

;~ 	$aResult = DllCall("User32.dll", "int", "UpdateLayeredWindow", "hwnd", $hWnd, "hwnd", $hDCDest, "ptr", $pPTDest, "ptr", $pSize, _
;~ 			"hwnd", $hDCSrce, "ptr", $pPTSrce, "int", $iRGB, "ptr", $pBlend, "int", $iFlags)
;~ 	Return SetError($aResult[0] = 0, 0, $aResult[0] <> 0)
;~ EndFunc   ;==>_WinAPI_UpdateLayeredWindow

Func _WinAPI_UpdateLayeredWindow($hWnd, $hDCDest, $pPTDest, $pSize, $hDCSrce, $pPTSrce, $iRGB, $pBlend, $iFlags)
	Local $aResult

	$aResult = DllCall("User32.dll", "int", "UpdateLayeredWindow", "hwnd", $hWnd, "hwnd", $hDCDest, "ptr", $pPTDest, "ptr", $pSize, _
			"hwnd", $hDCSrce, "ptr", $pPTSrce, "int", $iRGB, "ptr", $pBlend, "int", $iFlags)
	If @error Then Return SetError(1, 0, 0)
	Return SetError($aResult[0] = 0, 0, $aResult[0] <> 0)
EndFunc   ;==>_WinAPI_UpdateLayeredWindow

All tested on AutoIt 3.2.10 on WIN98SE

Attachments (0)

Change History (2)

comment:1 Changed 12 years ago by Gary

  • Milestone set to
  • Resolution set to Fixed
  • Status changed from new to closed

Fixed in version:

comment:2 Changed 11 years ago by Valik

  • Milestone changed from to

Fixing wrong milestone.

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

as closed The owner will remain Gary.

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

Note: See TracTickets for help on using tickets.