Function Reference


_WinAPI_AddIconTransparency

Adds a transparency to the specified 32 bits-per-pixel icon

#include <WinAPIRes.au3>
_WinAPI_AddIconTransparency ( $hIcon [, $iPercent = 50 [, $bDelete = False]] )

Parameters

$hIcon Handle to the icon.
$iPercent [optional] 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. Default is 80.
$bDelete [optional] Specifies whether to delete the icon after the function is successful, valid values:
    True - Icon will be deleted if the function succeeds.
    False - Do not delete, you must release the icon when you are finished using it (Default).

Return Value

Success: Handle to the newly created icon.
Failure: 0 and sets the @error flag to non-zero.

Remarks

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.

Related

_WinAPI_DestroyIcon

Example

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPIRes.au3>
#include <WinAPIShellEx.au3>

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

GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 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(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE