Funktionreferenz


_WinAPI_UpdateLayeredWindowEx


Updates a bitmap translucency of a layered window

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

Parameter

$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).

Rückgabewert

Success: True
Failure: False

Bemerkungen

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.

Beispiel

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

_GDIPlus_Startup()
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)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_Shutdown()
GUISetState(@SW_SHOW)

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

_WinAPI_DeleteObject($hBitmap)