函数参考


_WinAPI_Create32BitHBITMAP

Creates a 32 bits-per-pixel bitmap from the specified icon.

#Include <WinAPIEx.au3>
_WinAPI_Create32BitHBITMAP ( $hIcon [, $fDib [, $fDelete]] )

参数

$hIcon Handle to the source icon.
$fDib [可选参数] Specifies whether to create device-independent (DIB) or device-dependent (DDB) bitmap, valid values:
TRUE - Creates DIB.
FALSE - Creates DDB. (Default)
$fDelete [可选参数] 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)

返回值

Success Handle to the created bitmap.
失败: 返回 0 并设置 @error 标志为非 0 值.

注意/说明

The _WinAPI_Create32BitHBITMAP() creates a 32 bits-per-pixel bitmap with alpha chanel (if possible) from the icons
with any color depth. The function internally converts the specified icon to the 32 bits-per-pixel icon.

When you are finished using the bitmap, destroy it using the _WinAPI_DeleteObject() function.

相关

详情参考

None

示例/演示


#NoTrayIcon

#Include <GUIMenu.au3>
#Include <WinAPIEx.au3>

Opt('MustDeclareVars', 1)
Opt('TrayMenuMode', 3)

If _WinAPI_GetVersion() < '6.0' Then
    MsgBox(16, 'Error', 'Require Windows Vista or later.')
    Exit
EndIf

Global $hMenu, $Options, $Exit

$hMenu = TrayItemGetHandle(0)
$Options = TrayCreateItem('Options')
TrayCreateItem('')
$Exit  = TrayCreateItem('Exit')

_GUICtrlMenu_SetItemBmp($hMenu, 0, _WinAPI_Create32BitHBITMAP(_WinAPI_ShellExtractIcon(@SystemDir & '\shell32.dll', 207, 16, 16), 1, 1))
_GUICtrlMenu_SetItemBmp($hMenu, 2, _WinAPI_Create32BitHBITMAP(_WinAPI_ShellExtractIcon(@SystemDir & '\shell32.dll', 131, 16, 16), 1, 1))

TraySetState()

Do
Until TrayGetMsg() = $Exit