函数参考


_WinAPI_AddIconTransparency

为32位图标添加透明度

#Include <WinAPIEx.au3>
_WinAPI_AddIconTransparency ( $hIcon [, $iPercent [, $fDelete]] )

参数

$hIcon 图标句柄
$iPercent [可选参数] A value (in percent) that specifies how much to decrease the values of the alpha channel for the
specified icon. If this parameter is 0, the function returns a fully transparent icon.
$fDelete [可选参数] Specifies whether to delete the icon after the function is successful, valid values:
TRUE - 函数成功返回后删除图标
FALSE - 不删除且必须在使用完毕后指定删除

返回值

成功: 返回新建图标句柄
失败: 返回 0并设置@error非0

注意/说明

This function only works with 32 bits-per-pixel with alpha chanel (RGB + Alpha) icons. If the source icon
has no alpha chanel, the resulting icon will be the same as the source icon. If the source icon is non
32 bits-per-pixel, the function fails.

When you are finished using the icon, destroy it using the _WinAPI_DestroyIcon() function.

相关

详情参考

None

示例/演示


#Include <WinAPIEx.au3>

Opt('MustDeclareVars', 1)

Global Const $STM_SETIMAGE = 0x0172

Global $hIcon = _WinAPI_Create32BitHICON(_WinAPI_ShellExtractIcon(@SystemDir & '\shell32.dll', 1, 32, 32), 1)

GUICreate('MyGUI', 262, 108)
For $i = 0 To 3
    GUICtrlCreateIcon('', 0, 30 + 58 * $i, 38, 32, 32)
    GUICtrlSendMsg(-1, $STM_SETIMAGE, 1, _WinAPI_AddIconTransparency($hIcon, 100 - 25 * $i))
Next
_WinAPI_DestroyIcon($hIcon)
GUISetState()

Do
Until GUIGetMsg() = -3