更新分层窗口半透明位图.
#Include <WinAPIEx.au3>
_WinAPI_UpdateLayeredWindowEx ( $hWnd, $iX, $iY, $hBitmap [, $iOpacity [, $fDelete]] )
$hWnd | 分层窗口句柄. 窗口创建时指定有 $WS_EX_LAYERED. |
$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 | [可选参数] 源位图 Alpha 透明度值. |
$fDelete | [可选参数] 更新窗口后是否删除位图,有效值: TRUE - 函数成功后删除位图. FALSE - 不删除, 当使用完位图你必须释放. (默认) |
成功: | 返回 1. |
失败: | 返回 0,设置@error 标志为非 0 值. |
#Include <APIConstants.au3>
#Include <GDIPlus.au3>
#Include <Misc.au3>
#Include <WinAPIEx.au3>
Opt('MustDeclareVars', 1)
Global $hForm, $hImage, $hBitmap, $Opacity = 0, $Step = 3
_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & '\Extras\Exclamation.png')
$hForm = GUICreate('MyGUI', _GDIPlus_ImageGetWidth($hImage), _GDIPlus_ImageGetHeight($hImage), -1, -1, $WS_POPUPWINDOW, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST))
$hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_Shutdown()
GUISetState()
Do
_WinAPI_UpdateLayeredWindowEx($hForm, -1, -1, $hBitmap, $Opacity)
$Opacity += $Step
If ($Opacity = 0) Or ($Opacity = 255) Then
$Step = -$Step
Sleep(500)
EndIf
Sleep(10)
Until _IsPressed('1B')
_WinAPI_DeleteObject($hBitmap)