This topic has not yet been rated - Rate this topic

BufferedPaintRenderAnimation function

Applies to: desktop apps only

Paints the next frame of a buffered paint animation.

Syntax

BOOL BufferedPaintRenderAnimation(
  HWND hwnd,
  HDC hdcTarget
);

Parameters

hwnd

Type: HWND

Handle to the window in which the animations play.

hdcTarget

Type: HDC

Handle of the target DC on which the buffer is animated.

Return value

Type: BOOL

Returns TRUE if the frame has been painted, or FALSE otherwise.

Remarks

If this function returns TRUE, the application should do no further painting. If this function returns FALSE, the application should paint normally.

An application calls this function within its WM_PAINT handler. After BufferedPaintRenderAnimation paints an animation frame, an application will typically continue without performing its usual painting operations. If appropriate, an application may choose to render additional user interface (UI) over the top of the animation. The following code example, to be included as part of a larger body of code, shows how to use the animation painting functions.


    if (!_fBufferedPaintInit)
    {
        BufferedPaintInit();
        _fBufferedPaintInit = TRUE;
    }

    // Determine whether the paint message was generated by a softfade animation.
    if (!BufferedPaintRenderAnimation(hWnd, hdc))
    {
        // Initialize buffered paint parameters.
        BP_ANIMATIONPARAMS animParams = {sizeof(BP_ANIMATIONPARAMS)};
        animParams.style = BPAS_LINEAR; 
        animParams.dwDuration = 0;
        GetThemeTransitionDuration(hTheme, iPartId, iStateIdFrom, 
                iStateIdTo, TMT_TRANSITIONDURATIONS, &animParams.dwDuration);

        HDC hdcFrom, hdcTo;
        HANIMATIONBUFFER hbpAnimation = BeginBufferedAnimation(hWnd, hdc, &rc, 
                BPBF_COMPATIBLEBITMAP, NULL, &animParams, &hdcFrom, &hdcTo);
        if (hbpAnimation)
        {
            if (hdcFrom)
            {
                PaintImpl(hdcFrom, iPartId, iStateIdFrom /*, ...*/);
            }
            if (hdcTo)
            {
                PaintImpl(hdcTo, iPartId, iStateIdTo/*, ...*/);
            }

            EndBufferedAnimation(hbpAnimation, TRUE);
        }
        else
        {
            // Default to unbuffered paint
            PaintImpl(hdc, iPartId, iStateIdTo/*, ...*/);
       
        }
    }
    // Else do not paint because the BufferedPaintRenderAnimation function 
    // already did.
}


Requirements

Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2008

Header

Uxtheme.h

DLL

UxTheme.dll

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
What about non-client area border animation.
Since this calls WM_PAINT in a loop, how to you handle painting custom borders that are themed within a WM_NCPAINT call?
Small mistake for getting Transition Duration
The sample has a small mistake.
The Transition duration time should be read like this:
animParams.dwDuration = 0;
GetThemeTransitionDuration(hTheme, iPartId, iStateIdFrom, iStateIdTo, TMT_TRANSITIONDURATIONS, &animParams.dwDuration);

[ Good catch, this will be corrected. -- MSFT ]