HI,
VB.net
i drew a circle and an arc in the form (resolution to my laptop screen size)
I want timer one to be switched on when the mouse hoves in that particular circle and turn off when it moves off the circle.And Second timer will be switched on when the mouse hoves over arc and switches off when it moves towards that part of form (which does not have circle or arc.i.e Form -(circle+arc).

Can any body let me know how do i go about this?

Recommended Answers

All 8 Replies

Are the colours of the object solid? If so maybe you could check the point under the mouse. Other wise it'd be a mathmatical hit test.

timer one to be switched on when the mouse hoves in that particular circle and turn off when it moves off

Has there any HitTest method for a circle or arc drawn on a form or a picturebox, when the mouse hoverring on them?

My opinion it may be done on the calculation of the position of mousepointer in respect of the drawn circle or arc, when mouse moves or hovers on the container.

Has there any HitTest method for a circle or arc drawn on a form or a picturebox, when the mouse hoverring on them?

My opinion it may be done on the calculation of the position of mousepointer in respect of the drawn circle or arc, when mouse moves or hovers on the container.

............................................................
Thanks for the Answers
There is no hittest method in my code.
Should i use hittest method?can you please post some related sample code .
Otherwise ,should i calculate mouse position in the form with the help of another program and then write "if" control statements ?

Also my requirement is such that when the mouse hoves over the object timer is on.
Sometimes ,when the mousehoves in the area out of the object (arc) i.e away from the arc (in the form ) another timer will be on

Thanks in advance
Akhila

BASIC VERSION:
for example, if your area was a rectangle (RX,RY,RW,RH) and the box is 10,10,10,10 then If Mouse.X > RX and Mouse.X < RX + RW And Mouse.Y > RY And Mouse.Y < RY + RH then OverRectangle = True.

in this scenario the HitTest is If Mouse.X > RX and Mouse.X < RX + RW And Mouse.Y > RY And Mouse.Y < RY + RH then OverRectangle = True.

You would need to adjust the code for testing the area of a circle and an arc.

Alternatively once the mouse is within the designated area you may want to raise an event.

GREAT EXAMPLE
[Click Here](Click Here)

I try to show here a simple codes for mousemovement on a picturebox, which can help you.
Calculation is simple which J.C. already posted.

The codes here are

Public Class Form1
    Dim x1, y1, h1, w1 As Integer   'Variables for four corner position of the rectangle
    Dim tl As New ToolTip
    Dim P As PictureBox
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

        x1 = 0
        y1 = 0
        h1 = 0
        w1 = 0

        P.Dispose()
    End Sub

    Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click

        'Creating a new picturebox
        P = New PictureBox
        AddHandler P.MouseMove, AddressOf Me.Picture_MouseMove
        AddHandler P.Paint, AddressOf Me.Picture_Paint

        Me.Controls.Add(P)
        P.Top = 10
        P.Left = 10
        P.Width = 505
        P.Height = 450
        P.BorderStyle = BorderStyle.FixedSingle
        P.BackColor = Color.White
        P.Show()

        'assigning the position of the four corner of the rectangle
        x1 = 50
        y1 = 50
        h1 = 200
        w1 = 200


    End Sub

    Private Sub Picture_MouseMove(sender As Object, e As System.Windows.Forms.MouseEventArgs)

        'Calculating the position of the 
        'mouse pointer and showa tooltip
        'where you are.

        If ((e.Location.X >= x1) And (e.Location.X <= x1 + w1)) And ((e.Location.Y >= y1) And (e.Location.Y <= y1 + h1)) Then
            tl.SetToolTip(P, "You are in to the Rectangle")
        Else
            tl.SetToolTip(P, "You are out off the Rectangle")
        End If

    End Sub

    Private Sub Picture_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs)
        'Draw a rectangle
        Dim x As Graphics
        x = e.Graphics
        x.DrawRectangle(Pens.Black, x1, y1, w1, h1)

    End Sub
End Class

sure thanks a lot for the code. I will try it on my system. However i need to employ timers as well.

But, Can you please tell me how to transfer the readings my timer reads to an excel sheet,with headings?

Thanks
Can anybody suggest me how to increase the size of radiobutton please?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.