Function Reference


Updates a bitmap translucency of a layered window

#include <WinAPISysWin.au3>
_WinAPI_UpdateLayeredWindowEx ( $hWnd, $iX, $iY, $hBitmap [, $iOpacity = 255 [, $bDelete = False]] )


$hWnd Handle to a layered window. A layered window is created by specifying $WS_EX_LAYERED when its creating.
$iX The new position of the left side of the window.
$iY The new position of the top of the window.
$hBitmap Handle to the bitmap that will be set to the layered window.
$iOpacity [optional] The alpha transparency value to be used on the entire source bitmap. Default is 255.
$bDelete [optional] Specifies whether to delete the bitmap after updated the window, valid values:
    True - Bitmap will be deleted if the function succeeds.
    False - Do not delete, you must release the bitmap when you are finished using it (Default).

Return Value

Success: True
Failure: False


For best drawing performance by the layered window and any underlying windows, the layered window should be
as small as possible.

If $iX and $iY are both equal to (-1), the current window position will not change.


#include <GDIPlus.au3>
#include <Misc.au3>
#include <WinAPIHObj.au3>
#include <WinAPISysWin.au3>
#include <WindowsConstants.au3>

Local $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & '\Extras\Exclamation.png')
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), _GDIPlus_ImageGetWidth($hImage), _GDIPlus_ImageGetHeight($hImage), -1, -1, $WS_POPUPWINDOW, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST))
Local $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)

Local $iOpacity = 0, $iStep = 3
        _WinAPI_UpdateLayeredWindowEx($hForm, -1, -1, $hBitmap, $iOpacity)
        $iOpacity += $iStep
        If ($iOpacity = 0) Or ($iOpacity = 255) Then
                $iStep = -$iStep
Until _IsPressed('1B')