Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

Drawing Chord using API

Total Hit ( 2528)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


About Chords

A chord is a region bounded by the intersection of an ellipse and a line segment called a secant. The following illustration shows a chord drawn by using the Chord function.

When calling Chord, an application supplies the coordinates of the upper-left and lower-right corners of the ellipse's bounding rectangle, as well as the coordinates of two points defining two radials. A radial is a line drawn from the center of an ellipse's bounding rectangle to a point on the ellipse.

When the system draws the curved part of the chord, it does so by using the current arc direction for the specified device context. The default arc direction is counterclockwise. You can have your application reset the arc direction by calling the SetArcDirection function.

Step-By-Step Example

- Create a standard exe project
- Add one command button on the form1
- Add the following code in form1

Click here to copy the following block
Private Declare Function Chord Lib "gdi32" ( _
    ByVal hdc As Long, _
    ByVal nLeftRect As Long, _
    ByVal nTopRect As Long, _
    ByVal nRightRect As Long, _
    ByVal nBottomRect As Long, _
    ByVal nXRadial1 As Long, _
    ByVal nYRadial1 As Long, _
    ByVal nXRadial2 As Long, _
    ByVal nYRadial2 As Long) As Long

Private Declare Function SetArcDirection Lib "gdi32" ( _
    ByVal hdc As Long, _
    ByVal ArcDirection As Long) As Long

Const AD_CLOCKWISE = 2
Const AD_COUNTERCLOCKWISE = 1

Private Sub Command1_Click()
  Me.AutoRedraw = True
  Me.ScaleMode = vbPixels

  Line (5, 5)-(205, 205), , B

  SetArcDirection Me.hdc, AD_CLOCKWISE
  'SetArcDirection Me.hdc, AD_COUNTERCLOCKWISE

  Chord Me.hdc, 5, 5, 205, 205, 0, 205, 205, 0
End Sub


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.