UDF > WinAPIEx > Theme >


_WinAPI_BufferedPaintUnInit

Ferme l'opération de peinture en tampon pour le thread courant

#include <WinAPITheme.au3>
_WinAPI_BufferedPaintUnInit ( )

Valeur de retour

Succès: Retourne 1.
Échec: Retourne 0 et définit @error <> 0, @extended peut contenir le code d'erreur HRESULT.

Remarque

Cette fonction nécessite Windows Vista ou une version ultérieure.

En relation

_WinAPI_BufferedPaintInit

Voir aussi

Consultez BufferedPaintUnInit dans la librairie MSDN.

Exemple

#include <APIThemeConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <SendMessage.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPIGdiDC.au3>
#include <WinAPIHObj.au3>
#include <WinAPIIcons.au3>
#include <WinAPIMisc.au3>
#include <WinAPIRes.au3>
#include <WinAPIShellEx.au3>
#include <WinAPISys.au3>
#include <WinAPITheme.au3>
#include <WindowsConstants.au3>

If Number(_WinAPI_GetVersion()) < 6.0 Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Erreur', 'Nécessite Windows Vista ou une version ultérieure.')
    Exit
EndIf

; Charge un bitmap et une icône
Local $hTech = _WinAPI_LoadImage(0, @ScriptDir & '\Extras\Tech.bmp', $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE)
Local $hIcon = _WinAPI_ShellExtractIcon(@ScriptDir & '\Extras\NVIDIA.ico', 0, 256, 256)

; Crée une GUI
GUICreate('Test '& StringReplace(@ScriptName, '.au3', '()'), 302, 302, -1, -1, $WS_POPUP, $WS_EX_TOPMOST)
GUICtrlCreatePic('', 0, 0, 302, 302)
Local $hPic = GUICtrlGetHandle(-1)

; Initialise la peinture en tampon
_WinAPI_BufferedPaintInit()

; Sélectionne le bitmap dans le DC
Local $hDC = _WinAPI_GetDC($hPic)
Local $hSrcDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hSrcSv = _WinAPI_SelectObject($hSrcDC, $hTech)

; Commence l'opération de peinture en tampon
Local $hNewDC
Local $hBP = _WinAPI_BeginBufferedPaint($hSrcDC, _WinAPI_CreateRectEx(22, 22, 256, 256), $hNewDC, $BPBF_COMPATIBLEBITMAP, 0, 0, 160)

; Dessine l'icône avec alpha
_WinAPI_DrawIconEx($hNewDC, 22, 22, $hIcon)

; Termine l'opération de peinture en tampon et met à jour la référence DC
_WinAPI_EndBufferedPaint($hBP)

; Fusionne les ressources bitmap et libère les ressources
Local $hDestDC = _WinAPI_CreateCompatibleDC($hDC)
Local $hBitmap = _WinAPI_CreateCompatibleBitmapEx($hDC, 302, 302, 0x606060)
Local $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)

; Définit le bitmap dans le contrôle Pic
_SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap)
Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hBitmap Then
    _WinAPI_DeleteObject($hBitmap)
EndIf

; Ferme la peinture en tampon
_WinAPI_BufferedPaintUnInit()

GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE