Re: Mike D Sutton please need help....
- From: vonclausowitz@xxxxxxxxx
- Date: 28 Jun 2006 09:36:36 -0700
Mike,
great stuff but how do I combine my Form_Paint with your code?
Private Sub Form_Paint()
Dim i
Dim OldMode As Long, OldCol As Long
Cls
OldMode = SetBkMode(Me.hdc, OPAQUE)
OldCol = SetBkColor(Me.hdc, vbWhite)
For Each i In Ropes
i.Draw Me
Next
For Each i In Boxes
i.Draw Me
Next
End Sub
Mike D Sutton schreef:
Thank you very very much, you've made an amateur very happy.<code snipped>
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:
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/
.
- Follow-Ups:
- Re: Mike D Sutton please need help....
- From: Mike D Sutton
- Re: Mike D Sutton please need help....
- References:
- Mike D Sutton please need help....
- From: vonclausowitz
- Re: Mike D Sutton please need help....
- From: Mike D Sutton
- Re: Mike D Sutton please need help....
- From: vonclausowitz
- Re: Mike D Sutton please need help....
- From: Mike D Sutton
- Re: Mike D Sutton please need help....
- From: vonclausowitz
- Re: Mike D Sutton please need help....
- From: Mike D Sutton
- Re: Mike D Sutton please need help....
- From: vonclausowitz
- Re: Mike D Sutton please need help....
- From: Mike D Sutton
- Re: Mike D Sutton please need help....
- From: vonclausowitz
- Re: Mike D Sutton please need help....
- From: Mike D Sutton
- Mike D Sutton please need help....
- Prev by Date: Re: Mike D Sutton please need help....
- Next by Date: Re: Mike D Sutton please need help....
- Previous by thread: Re: Mike D Sutton please need help....
- Next by thread: Re: Mike D Sutton please need help....
- Index(es):
Loading