1. 0

An enhanced version of DrawPenData. Besides displaying the pen data in an HPENDATA object as a trail of visible ink, DrawPenDataEx can govern the speed at which the data is rendered, a process called animation.

int DrawPenDataEx( HDC hdc, LPRECT lprectVP, HPENDATA hpndt, UINT iStrkFirst, UINT iStrkLast, UINT iPntFirst, UINT iPntLast, ANIMATEPROC lpfnAnimateCB, LPANIMATEINFO lpai, UINT fuFlags )



Handle to a device context.


Viewport rectangle, usually the bounding rectangle of the pen data, in client coordinates. The ink is scaled to fit the specified rectangle. If this parameter is NULL, the bounding rectangle of the ink in hpndt is used, in whatever coordinate system it happens to be in.


Handle to a pen data object.


Index of the first stroke to display.


Index of the last stroke to display.


Index of the first point in the first stroke to display.


Index of the last point in the last stroke to display.


Pointer to a callback function instance, or NULL. The callback function is called periodically during drawing, and animation is controlled by values in the structure addressed by the next parameter, lpai, which should not be NULL. If lpfnAnimateCB and the speed in the lpai structure parameters are NULL, the specified pen data is drawn without regard to timing information, and no callback functions are generated. See AnimateProc for a description of the callback function.


Address of an ANIMATEINFO structure that specifies animation parameters to control how the pen data is drawn. If this parameter is NULL, the function draws the specified pen data without regard to timing information, and no callback functions are generated; otherwise, the caller must initialize the cbSize member to sizeof( ANIMATEINFO ).


This flag can be 0 or one of the following values:


Use the GDI pen already selected into the specified device context. If this flag is set, any pen formatting stored in hpndt is ignored and all strokes are drawn with a single width and color. The DrawPenData function uses this flag.


Paint selected strokes in the specified range. A solid pen is used, with a width slightly larger than the stroke width. This flag can be used only for drawing and is ignored for animation. It is incompatible with DPD_HDCPEN.

Return Value

Returns PDR_OK if successful. Attempting to draw an empty HPENDATA (containing no strokes) also returns PDR_OK. Otherwise, returns one of the following:

Drawing aborted because pen data became invalid after a callback or yield.
Callback cancel or impasse. An impasse occurs when the user attempts to animate with 0 percent speed (that is, pause), but the callback interval is on a per-stroke basis.
Pen data is compressed.
Bad animation structure, invalid sampling rate (0 or less) in pen data header, illegal flags, or other error.
Memory error.
Invalid pen data. This value is also returned if the pen data is destroyed or corrupted during drawing or animation. This error can occur if an application is drawing a large pen data object and then destroys the data before drawing is complete.
Invalid point index.
Invalid stroke index.
Could not convert old pendata.


is a general-purpose drawing function for rendering pen data objects. The calling application can use the timing information in the strokes to animate the pen data and specify which subset of the pen data should be drawn.

Partial pen data objects can be drawn by specifying first and last strokes and points with iStrkFirst, iStrkLast, iPntFirst, and iPntLast. Set beginning values to 0 and ending values to IX_END to display the entire pen data object. The function fails if any of these values lie outside the ranges available in the pen data. The stroke values must be between 0 and the total number of strokes in the pen data, and the point indices must be between 0 and the number of points in their stroke.

DrawPenDataEx can display only a set of sequential strokes with a single call. To draw nonsequential strokespics/PENAPI00090001.gifsay, the second, fifth, and eighth strokes of the pen datapics/PENAPI00090001.gifrequires multiple calls to DrawPenDataEx.

Ink displayed by DrawPenDataEx differs slightly from the original rendering, as described in the DrawPenData topic. However, DrawPenDataEx can automatically display the ink with its original color and width, saving the application the burden of resetting the current GDI pen characteristics. To draw the ink according to the GDI settings, set fuFlags to DPD_HDCPEN.

If lpfnAnimateCB is not NULL, the specified callback function must return TRUE to continue drawing, or FALSE to terminate drawing.

An application can modify the pen data while it is being rendered, for example, during an animation callback, task switching, or internal yield. However, doing so can make internal pointers or data invalid and result in unpredictable behavior. For this reason, editing the pen data during rendering is not recommended.

See Also

, DrawPenData, RedisplayPenData, DrawPenDataFmt, ANIMATEINFO

Software for developers
Delphi Components
.Net Components
Software for Android Developers
More information resources
Unix Manual Pages
Delphi Examples