Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fillcolor or equivalent for a triangle 1

Status
Not open for further replies.

dileas

Technical User
Nov 21, 2001
5
GB
Any oldies like me out there who can help with VB3. I am trying to draw solid coloured triangles and am stumped. Can anyone advise, please.

TIA
 
How are yo drawing the triangle? Using set of Line statements?

You might want to consider using the API, and the follwoing two functions: SetPolyFillMode and Polygon
 
In fact, here's a quick example. You'll need a form with a picturebox and a command button.
[tt]
Option Explicit
Private Declare Function SetPolyFillMode Lib "gdi32" (ByVal hdc As Long, ByVal nPolyFillMode As Long) As Long
Private Declare Function Polygon Lib "gdi32" (ByVal hdc As Long, lpPoint As POINTAPI, ByVal nCount As Long) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Private Const ALTERNATE = 1
Private Const WINDING = 2


Private Sub Command1_Click()
Dim pts() As POINTAPI

ReDim pts(3)

pts(0).x = 20
pts(0).y = 20
pts(1).x = 100
pts(1).y = 100
pts(2).x = 20
pts(2).y = 100

Picture1.FillStyle = 0 ' solid fill

Call SetPolyFillMode(Picture1.hdc, WINDING)
Call Polygon(Picture1.hdc, pts(0), 3)
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top