CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: round circle

  1. #1
    Join Date
    Aug 2001
    Location
    india(rajasthan)
    Posts
    2

    round circle

    how we create a small circle at the edge on another circle and move this small circle on it like a clock



  2. #2

    Re: round circle

    >we create a small circle

    To create a circle U can use function circle.

    Circle [Step](x, y), radius[, color]

    This function creates a circle on a form, with API FillRgn [Public Declare Function FillRgn Lib "gdi32" Alias "FillRgn" (ByVal hdc As Long, ByVal hRgn As Long, ByVal hBrush As Long) As Long ] also U can fill it.


    hi, brt




  3. #3
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Re: round circle

    You can also use the SHAPE control. It provides a variaty of shapes, Rectangles,Squares,Circles Ovals etc. it provides for line types,width, Fill Patterns, etc

    John G

  4. #4
    Join Date
    Jan 2001
    Posts
    165

    Re: round circle

    Use the shape control to make a circle on the form and set its index property to 0. Make sure that the width and height are the same so it is a circle and not an oval. Then add a timer and a command button and paste this code to the form.

    private Sub Command1_Click()
    If Shape1.Count = 1 then Load Shape1(1)

    Shape1(1).Left = Shape1(0).Left + Shape1(0).Width
    Shape1(1).Top = Shape1(0).Top + (0.5 * Shape1(0).Height) - (0.125 * Shape1(0).Height)
    Shape1(1).Height = (0.25 * Shape1(0).Height)
    Shape1(1).Width = (0.25 * Shape1(0).Width)
    Shape1(1).Visible = true

    Timer1.Interval = 250
    Timer1.Enabled = true
    End Sub

    private Sub Timer1_Timer()
    Dim nRadius as Integer, nX as Integer, nY as Integer
    Const pi = 3.14159265358979

    static nAngle as Integer

    nRadius = 0.5 * (Shape1(0).Width + Shape1(1).Width)

    nAngle = nAngle + 10
    If nAngle > 360 then
    nAngle = 0
    Timer1.Enabled = false
    Exit Sub
    End If

    nX = Cos(CDbl(nAngle) * pi / 180) * nRadius
    nY = Sin(CDbl(nAngle) * pi / 180) * nRadius

    Shape1(1).Left = Shape1(0).Left + 0.5 * Shape1(0).Width + nX - 0.5 * (Shape1(1).Width)
    Shape1(1).Top = Shape1(0).Top + 0.5 * Shape1(0).Height - nY - 0.5 * (Shape1(1).Height)
    End Sub



    This will draw a circle 1/4 the size of the initial circle and place it on the right edge of the large circle. It will then rotate the smaller circle around the larger circle in revolutions of 10 degrees every .25 seconds until it has made 1 full revolution.

    -K


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured