PolyBezier Function

Declare Function PolyBezier Lib "gdi32.dll" (ByVal hdc As Long, lppt As POINT_TYPE, ByVal cPoints As Long) As Long

Platforms

Description & Usage

PolyBezier draws a series of cubic Bézier curves on a device. Each Bézier curve is drawn using the device's current pen. The function begins drawing the curves at a start point and draws each subsequent curve starting at the point where the previous one ended (for example, if the second curve ended at (100,50), the third curve would begin at (100,50) as well).

Return Value

If an error occured, the function returns 0 (Windows NT, 2000: use GetLastError to get the error code). If successful, the function returns a non-zero value.

Visual Basic-Specific Issues

None.

Parameters

hdc
A handle to a device context to the device to draw the Bézier curves on.
lppt
An array containing all the end points and control points for the Bézier curves. The first point is the starting point for the first curve. Each set of three points following the first identifies how to draw each curve: the first two points in the set are the two control points, and the third point is the end point of the curve.
cPoints
The number of elements in the array passed as lppt. This value will have to be one more than three times the number of curves to draw.

Example

' This code is licensed according to the terms and conditions listed here.

' Draw two Bézier curves on window Form1 using the
' solid black stock pen.  The coordinates of the curves appear in
' the example code.
Dim hPen As Long  ' handle to the solid black stock pen
Dim hOldPen As Long  ' handle to Form1's previous pen
Dim pts(0 To 6) As POINT_TYPE  ' array of points for the curves
Dim retval As Long  ' return value

' Load the seven points defining the two Bézier curves
' into the array.  The first four points define the first curve.
pts(0).x = 100: pts(0).y = 100  ' 1st curve starts at (100,100)
pts(1).x = 125: pts(1).y = 75   ' control point (125,75)
pts(2).x = 150: pts(2).y = 125  ' control point (150,125)
pts(3).x = 175: pts(3).y = 100  ' 1st curve ends at (175,100)
' The next three define the second curve, starting at (175,100)
pts(4).x = 225: pts(4).y = 50   ' control point (225,50)
pts(5).x = 300: pts(5).y = 150  ' control point (300, 150)
pts(6).x = 250: pts(6).y = 200  ' 2nd curve ends at (250,200)

' Get a handle to the solid black stock pen.
hPen = GetStockObject(BLACK_PEN)
' Select the pen for use in Form1.
hOldPen = SelectObject(Form1.hDC, hPen)
' Draw the two Bézier curves.
retval = PolyBezier(Form1.hDC, pts(0), 7)
' Select the previous pen used by Form1.
retval = SelectObject(Form1.hDC, hOldPen)

See Also

PolyBezierTo

Category

Lines & Curves

Go back to the alphabetical Function listing.
Go back to the Reference section index.


Last Modified: November 10, 1999
This page is copyright © 1999 Paul Kuliniewicz. Copyright Information Revised October 29, 2000
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/p/polybezier.html