views:

95

answers:

2

Hello

I have found API functions to draw a star using VB6: what I need is to colour sections of each point of the star according to data-driven parameters: thus if the parameter passed is 1, I want to colour the part of the selected star point red up to 1/10th of its length measured from the circunference of the circle around which the star is built; if 2, 2/10ths of the star point green, etc.

I have found the API function CreatePolygonRgn so I can change the colour of the whole of a particular star point but baffled as to how a polygon can be defined using only one X and Y parameter: if I change the X and Y for a given star point, I get results that don't seem to make sense TKIF Charles Geach
se

+1  A: 

The excellent vbAccelerator gives some VB6 code. I haven't tested this myself. Be aware that points() is an array, and even though it looks like you are only passing the first element, you are actually giving the API call access to the whole array. The first argument to CreatePolygonRgn is not a single point, but an array of points.

I hope that helps you understand what's going on, and you can get your star code written.

Type POINTAPI
  X As Long
  Y As Long
End Type
Declare Function CreatePolygonRgn Lib "gdi32" _
  (lpPoint As POINTAPI, ByVal nCount As Long, _
   ByVal nPolyFillMode As Long) As Long

Sub Test()
  Const ALTERNATE = 1 ' ALTERNATE and WINDING are '
  Const WINDING = 2   ' constants for FillMode. '

   Dim points(1 To 5) as POINTAPI
   ' fill in points .. '
   CreatePolygonRgn(points(1), 5, WINDING)
End Sub
MarkJ
A: 

Instead of messing around with API calls, I would like to suggest an alternative. It sounds to me like you will have (at most) 11 different looking stars (0 to 10). If this were my project, I would create 11 images using a graphics application of your choice. Then, depending on the value of the variable, selectively show whichever image you want.

G Mastros