Re: Mike D Sutton please need help....



Mike,

I managed to get things on the form by putting the code in the Form
Load event, like this:

Private Sub Form_Load()

Dim B As Box
Dim CircPts() As POINTAPI
Dim LoopPts As Long
Dim PtCaption As String
Const NumPts As Long = 6

If Me.Tag <> "fixed" Then
Me.Move 0, 0, Main.ScaleWidth, Main.ScaleHeight
' restrict sizing xmin, ymin xmax, ymax
FixSize Me, 5340, 5565, 100000, 100000
Me.Tag = "fixed"
End If

Font.Size = 24
Boxes.Add NewBox(Me.ImageList1.ListImages(1).Picture,
LinkAnalysis.ScaleWidth \ 2, LinkAnalysis.ScaleHeight \ 2, "THAQI,
Hashim", vbBlue)

' This is the call that does all the work
CircPts = GetCirclePoints(NumPts, 1200, 2300, 1500)

For LoopPts = 1 To NumPts - 1
With CircPts(LoopPts)
Font.Size = 24
Boxes.Add NewBox(Me.ImageList1.ListImages(4).Picture, .x, .y,
"CEKU, Agim", vbBlue)
Font.Size = 8
Ropes.Add NewRope(Boxes(1), Boxes(LoopPts + 1), " commander ")
End With
Next LoopPts

End Sub

The problem is that I print the first Box in the middle of the screen
and then all the
others should go around that one in a circle and get connected by Ropes
to the middle box.

Marco

Mike D Sutton schreef:

Thank you very very much, you've made an amateur very happy.
It is finally working like I want.
The second Question I have is how to load all these icons in a circle
using the next code:
<code snipped>
I tried this with buttons but now I need this code with the boxes and
ropes.

To get the positions of points around a circle you need to use a little trigonometry. Drop a timer control on a blank
form then paste in this code and run:

'***
Private Type PointAPI
X As Long
Y As Long
End Type

Private Function GetCirclePoints( _
ByVal inNumPoints As Long, ByVal inRadius As Long, _
Optional ByVal inXOff As Long = 0, _
Optional ByVal inYOff As Long = 0, _
Optional ByVal inOffsetRotation As Long = 0) As PointAPI()
Dim RetArr() As PointAPI, LoopPts As Long
Dim Radians As Double

Const Pi As Double = 3.14159
Const TwoPi As Double = Pi * 2

If (inNumPoints > 0) Then ' Allocate return array
ReDim RetArr(0 To inNumPoints - 1) As PointAPI

For LoopPts = 0 To inNumPoints - 1 ' Calculate coordinates of each point
Radians = ((LoopPts / inNumPoints) + (inOffsetRotation / 360)) * TwoPi
RetArr(LoopPts).X = (Cos(Radians) * inRadius) + inXOff
RetArr(LoopPts).Y = (Sin(Radians) * inRadius) + inYOff
Next LoopPts

' Return point array
GetCirclePoints = RetArr
End If
End Function

Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 20
Timer1.Enabled = True
End Sub

Private Sub Form_Paint()
Dim CircPts() As PointAPI
Dim LoopPts As Long
Dim PtCaption As String

Const NumPts As Long = 6

' This is the call that does all the work
CircPts = GetCirclePoints(NumPts, 1200, 2300, 1500, Timer() * 25)

For LoopPts = 0 To NumPts - 1
With CircPts(LoopPts)
Me.Circle (.X, .Y), 200, vbRed
PtCaption = CStr(LoopPts + 1)
Me.PSet (.X - (Me.TextWidth(PtCaption) \ 2), _
.Y - (Me.TextHeight(PtCaption) \ 2)), Me.BackColor
Me.Print PtCaption
End With
Next LoopPts
End Sub
'***

It simply calculates the positions of 6 points around a circle and draws them to the form. The GetCirclePoints()
function does the work of calculating the points and also includes an offset rotation (in degrees) which is used in the
demo to spin the circles over time.
Hope this helps,

Mike


- Microsoft Visual Basic MVP -
E-Mail: EDais@xxxxxxxx
WWW: Http://EDais.mvps.org/

.


Loading