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 Polygon with ALTERNATE and WINDING style

Total Hit ( 3830)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


Click here to copy the following block
Private Const ALTERNATE = 1
Private Const WINDING = 2

Private Type POINTAPI
  x As Long
  y As Long
End Type

Private Declare Function SetPolyFillMode Lib "gdi32" (ByVal hdc As Long, ByVal nPolyFillMode As Long) As Long
Private Declare Function GetPolyFillMode Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function Polygon Lib "gdi32" (ByVal hdc As Long, lpPoint As POINTAPI, ByVal nCount As Long) As Long
Private Sub Form_Paint()
  Dim PolyPoints(1 To 5) As POINTAPI, Cnt As Long
  
  Const PentagramWidth As Long = 150
  
  'initialize the points
  PolyPoints(1).x = PentagramWidth / 2
  PolyPoints(1).y = 0
  PolyPoints(2).x = (PentagramWidth / 4) * 3
  PolyPoints(2).y = PentagramWidth
  PolyPoints(3).x = 0
  PolyPoints(3).y = PentagramWidth / 3
  PolyPoints(4).x = PentagramWidth
  PolyPoints(4).y = PentagramWidth / 3
  PolyPoints(5).x = PentagramWidth / 4
  PolyPoints(5).y = PentagramWidth
  
  'set the form's fillmode to solid and fillcolor to red
  Me.FillStyle = vbSolid
  Me.FillColor = vbRed
  
  'set the polygon fillmode to winding
  If GetPolyFillMode(Me.hdc) <> WINDING Then SetPolyFillMode Me.hdc, WINDING
  
  '//draw the polygon
  Polygon Me.hdc, PolyPoints(1), 5
  
  '//move the points to the right
  For Cnt = 1 To 5
    PolyPoints(Cnt).x = PolyPoints(Cnt).x + PentagramWidth + 20
  Next Cnt
  
  '//set the polygon fillmode to alternate
  SetPolyFillMode Me.hdc, ALTERNATE
  
  '//draw the second polygon
  Polygon Me.hdc, PolyPoints(1), 5
  
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.