函数参考


_WinAPI_BeginBufferedPaint

Begins a buffered paint operation.

#Include <WinAPIEx.au3>
_WinAPI_BeginBufferedPaint ( $hDC, $tTarget, ByRef $hNewDC [, $iFormat [, $iFlags [, $tExclude [, $iAlpha]]]] )

参数

$hDC Handle of the target DC on which the buffer will be painted.
$tTarget $tagRECT structure that specifies the area of the target DC in which to paint.
$hNewDC Handle of the new device context.
$iFormat [可选参数] The format of the buffer. This parameter can be one of the following values.

$BPBF_COMPATIBLEBITMAP
$BPBF_DIB
$BPBF_TOPDOWNDIB
$BPBF_TOPDOWNMONODIB
$iFlags [可选参数] The additional flags, one or more of the following values.

$BPPF_ERASE
$BPPF_NOCLIP
$BPPF_NONCLIENT
$tExclude [可选参数] $tagRECT structure that specifies the area which is excluded from the clipping region.
$iAlpha [可选参数] The alpha transparency value to be used on the entire source bitmap. If this parameter is not
specified or (-1), the source buffer is copied to the destination with no blending.

返回值

Success The handle to the buffered paint context.
失败: 返回 0 并设置 @error 标志为非 0 值.

注意/说明

本函数需要 Windows Vista 或更高版本系统.

相关

详情参考

在MSDN中搜索


示例/演示


#Include <APIConstants.au3>
#include <GUIConstantsEx.au3>
#Include <WinAPIEx.au3>

Opt('MustDeclareVars', 1)

Global Const $STM_SETIMAGE = 0x0172
Global Const $STM_GETIMAGE = 0x0173

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

Global $hPic, $hObj, $hIcon, $hTech, $hBitmap, $hBP, $hDC, $hSrcDC, $hSrcSv, $hDestDC, $hDestSv, $hNewDC

; 加载位图和图标
$hTech = _WinAPI_LoadImage(0, @ScriptDir & '\Extras\Tech.bmp', $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE)
$hIcon = _WinAPI_ShellExtractIcon(@ScriptDir & '\Extras\NVIDIA.ico', 0, 256, 256)

; 创建 GUI
GUICreate('MyGUI', 302, 302, -1, -1, $WS_POPUP, $WS_EX_TOPMOST)
GUICtrlCreatePic('', 0, 0, 302, 302)
$hPic = GUICtrlGetHandle(-1)

; 初始化缓冲区绘画
_WinAPI_BufferedPaintInit()

; 选择位图到设备上下文
$hDC = _WinAPI_GetDC($hPic)
$hSrcDC = _WinAPI_CreateCompatibleDC($hDC)
$hSrcSv = _WinAPI_SelectObject($hSrcDC, $hTech)

; 开始缓冲区绘画操作
$hBP = _WinAPI_BeginBufferedPaint($hSrcDC, _WinAPI_CreateRectEx(22, 22, 256, 256), $hNewDC, $BPBF_COMPATIBLEBITMAP, 0, 0, 160)

; 描绘含透明度的图标
_WinAPI_DrawIconEx($hNewDC, 22, 22, $hIcon)

; 结束缓冲区绘画操作并更新引用设备上下文
_WinAPI_EndBufferedPaint($hBP)

; 合并位图并释放资源
$hDestDC = _WinAPI_CreateCompatibleDC($hDC)
$hBitmap = _WinAPI_CreateCompatibleBitmapEx($hDC, 302, 302, 0x606060)
$hDestSv = _WinAPI_SelectObject($hDestDC, $hBitmap)
_WinAPI_BitBlt($hDestDC, 1, 1, 300, 300, $hSrcDC, 0, 0, $MERGECOPY)
_WinAPI_SelectObject($hDestDC, $hDestSv)
_WinAPI_DeleteDC($hDestDC)
_WinAPI_SelectObject($hSrcDC, $hSrcSv)
_WinAPI_DeleteDC($hSrcDC)
_WinAPI_ReleaseDC($hPic, $hDC)
_WinAPI_DeleteObject($hTech)
_WinAPI_DestroyIcon($hIcon)

; 设置位图到控件
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
$hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

; 关闭缓冲区绘画
_WinAPI_BufferedPaintUnInit()

GUISetState()

Do
Until GUIGetMsg() = -3