Arc Function

Declare Function Arc Lib "gdi32.dll" (ByVal hdc As Long, ByVal nLeftRect As Long, ByVal nTopRect As Long, ByVal nRightRect As Long, ByVal nBottomRect As Long, ByVal nXStartArc As Long, ByVal nYStartArc As Long, ByVal nXEndArc As Long, ByVal nYEndArc As Long) As Long

Platforms

Description & Usage

Arc draws an elliptical arc on a device using the device's current pen. The ellipse which the arc lies on is inscribed within the bounding rectangle coordinates passed to the function. The start and end points are determined by two radials. The radials begin at the center of the ellipse and extend through the given radial point (either the start or end one); where they intersect the ellipse is where the start and end points of the arc are. Windows 95/98: The arc is always drawn counterclockwise from the start point to the end point. Windows NT/2000: The direction the arc is drawn in depends on the device's current setting.

Return Value

If an error occured while attempting to draw the arc, the function returns 0 (Win NT/2000: call GetLastError to get the errror code). If the function completed successfully, it returns a non-zero value.

Visual Basic-Specific Issues

None.

Parameters

hdc
A handle to a device context of the device to draw the arc on.
nLeftRect
The x coordinate of the upper-left point of the ellipse's bounding rectangle.
nTopRect
The y coordinate of the upper-left point of the ellipse's bounding rectangle.
nRightRect
The x coordinate of the lower-right point of the ellipse's bounding rectangle.
nBottomRect
The y coordinate of the lower-right point of the ellipse's bounding rectangle.
nXStartArc
The x coordinate of the radial point that determines the arc's starting point.
nYStartArc
The y coordinate of the radial point that determines the arc's starting point.
nXEndArc
The x coordinate of the radial point that determines the arc's ending point.
nYEndArc
The y coordinate of the radial point that determines the arc's ending point.

Example

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

' Draw the arc that forms the top half of an ellipse.  The ellipse
' is centered at (100, 100), has a width of 200, and has a height of 100.  The arc is drawn
' on window Form1 using the black solid stock pen.
Dim hpen As Long  ' handle to the black solid pen
Dim holdpen As Long  ' handle to window Form1's previously selected pen
Dim retval As Long  ' return value

' Get a handle to the solid black pen and set it as Form1's drawing pen.
hpen = GetStockObject(BLACK_PEN)  ' get a handle to the pen
holdpen = SelectObject(Form1.hDC, hpen)  ' set it as Form1's current pen

' The ellipse is determined by the bounding rectangle (0,50)-(200,150).
' The radial to (200, 100) is due right; the radial to (0, 100) is due left.
retval = Arc(Form1.hDC, 0, 50, 200, 150, 200, 100, 0, 100)

' Restore Form1's previous pen selection.
retval = SelectObject(Form1.hDC, holdpen)  ' set the old pen back

See Also

AngleArc, ArcTo, Ellipse, GetArcDirection, SetArcDirection

Category

Lines & Curves

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


Last Modified: July 27, 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/a/arc.html