Mouse Hover over round Area?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lars Netzel

    Mouse Hover over round Area?

    Hi!

    I have a round area which I want to be able to move the mouse over and fire
    off events... how do I do that?

    I have drawn a FillPie Graphics and I feel that there has to be a way of
    getting to know if the mouse is over that area since I have the coordinates
    to paint the Pie but I don't know where to start or what to look for really.

    Best Regard
    /Lars


  • Cor Ligthert

    #2
    Re: Mouse Hover over round Area?

    Lars,

    Did you ever see this nice sample I once have made in the past?

    It should have parts of your question.
    (it needs only a form and paste the code in)

    I hope you can use it?

    Cor

    \\\made by Cor Ligthert from ideas I got from Herfried. K. Wagner and Fergus
    Cooney
    Private WithEvents button1 As New Button
    Private mouseX, mouseY As Integer
    Private myMouseDown As Boolean
    Private Sub Form1_Load(ByVa l sender As System.Object, _
    ByVal e As System.EventArg s) Handles MyBase.Load
    Dim g As New System.Drawing. Drawing2D.Graph icsPath
    g.AddString("HT H" & vbCrLf & "Cor", _
    System.Drawing. FontFamily.Gene ricSansSerif, _
    System.Drawing. FontStyle.Bold, 200, _
    New Point(0, 0), _
    System.Drawing. StringFormat.Ge nericDefault)
    Me.BackColor = Color.Red
    Me.Region = New System.Drawing. Region(g)
    g.Dispose()
    Me.AutoScaleBas eSize = New System.Drawing. Size(0, 0)
    Me.ClientSize = New System.Drawing. Size(500, 450)
    button1.BackCol or = System.Drawing. SystemColors.Ac tiveCaptionText
    button1.ForeCol or = System.Drawing. Color.Black
    button1.Locatio n = New System.Drawing. Point(425, 18)
    button1.Size = New System.Drawing. Size(20, 20)
    Me.Controls.Add (button1)
    button1.Text = "X"
    Me.Location = New System.Drawing. Point(50, 50)
    End Sub
    Private Sub Button1_Click(B yVal sender As Object, _
    ByVal e As System.EventArg s) Handles button1.Click
    Me.Close()
    End Sub
    Private Sub Form1_MouseDown (ByVal sender As Object, ByVal _
    e As System.Windows. Forms.MouseEven tArgs) Handles MyBase.MouseDow n
    myMouseDown = True
    mouseX = Cursor.Position .X - Me.Location.X
    mouseY = Cursor.Position .Y - Me.Location.Y
    End Sub
    Private Sub Form1_MouseMove (ByVal sender As Object, ByVal e _
    As System.Windows. Forms.MouseEven tArgs) Handles MyBase.MouseMov e
    Static LastCursor As Point
    Dim NowCursor As Point = New Point(Cursor.Po sition.X,
    Cursor.Position .Y)
    If Point.op_Inequa lity(NowCursor, LastCursor) Then
    If myMouseDown Then
    Me.Location = New System.Drawing. Point(Cursor.Po sition.X _
    - mouseX, Cursor.Position .Y - mouseY)
    End If
    LastCursor = Cursor.Position
    End If
    End Sub
    Private Sub Form1_MouseUp(B yVal sender As Object, ByVal e As _
    System.Windows. Forms.MouseEven tArgs) Handles MyBase.MouseUp
    myMouseDown = False
    End Sub
    ///


    "Lars Netzel" <[stop_spam]@host.topdomain >[color=blue]
    > Hi!
    >
    > I have a round area which I want to be able to move the mouse over and[/color]
    fire[color=blue]
    > off events... how do I do that?
    >
    > I have drawn a FillPie Graphics and I feel that there has to be a way of
    > getting to know if the mouse is over that area since I have the[/color]
    coordinates[color=blue]
    > to paint the Pie but I don't know where to start or what to look for[/color]
    really.[color=blue]
    >
    > Best Regard
    > /Lars
    >
    >[/color]


    Comment

    • Lars Netzel

      #3
      Re: Mouse Hover over round Area?

      Yes, it helps a little to understand how to get the posistion of the mouse
      Cursor and compare with that op_Inequality but I'm not sure how to get the
      position to compare with... I mean, if I have the mouseCursor.. Do I need to
      loop thru all the points within the Round Area and run the op_inequality
      test then, and how to I get the points for that Area...?

      /Lars






      "Cor Ligthert" <notfirstname@p lanet.nl> skrev i meddelandet
      news:uQzUO%236n EHA.1296@TK2MSF TNGP09.phx.gbl. ..[color=blue]
      > Lars,
      >
      > Did you ever see this nice sample I once have made in the past?
      >
      > It should have parts of your question.
      > (it needs only a form and paste the code in)
      >
      > I hope you can use it?
      >
      > Cor
      >
      > \\\made by Cor Ligthert from ideas I got from Herfried. K. Wagner and[/color]
      Fergus[color=blue]
      > Cooney
      > Private WithEvents button1 As New Button
      > Private mouseX, mouseY As Integer
      > Private myMouseDown As Boolean
      > Private Sub Form1_Load(ByVa l sender As System.Object, _
      > ByVal e As System.EventArg s) Handles MyBase.Load
      > Dim g As New System.Drawing. Drawing2D.Graph icsPath
      > g.AddString("HT H" & vbCrLf & "Cor", _
      > System.Drawing. FontFamily.Gene ricSansSerif, _
      > System.Drawing. FontStyle.Bold, 200, _
      > New Point(0, 0), _
      > System.Drawing. StringFormat.Ge nericDefault)
      > Me.BackColor = Color.Red
      > Me.Region = New System.Drawing. Region(g)
      > g.Dispose()
      > Me.AutoScaleBas eSize = New System.Drawing. Size(0, 0)
      > Me.ClientSize = New System.Drawing. Size(500, 450)
      > button1.BackCol or = System.Drawing. SystemColors.Ac tiveCaptionText
      > button1.ForeCol or = System.Drawing. Color.Black
      > button1.Locatio n = New System.Drawing. Point(425, 18)
      > button1.Size = New System.Drawing. Size(20, 20)
      > Me.Controls.Add (button1)
      > button1.Text = "X"
      > Me.Location = New System.Drawing. Point(50, 50)
      > End Sub
      > Private Sub Button1_Click(B yVal sender As Object, _
      > ByVal e As System.EventArg s) Handles button1.Click
      > Me.Close()
      > End Sub
      > Private Sub Form1_MouseDown (ByVal sender As Object, ByVal _
      > e As System.Windows. Forms.MouseEven tArgs) Handles MyBase.MouseDow n
      > myMouseDown = True
      > mouseX = Cursor.Position .X - Me.Location.X
      > mouseY = Cursor.Position .Y - Me.Location.Y
      > End Sub
      > Private Sub Form1_MouseMove (ByVal sender As Object, ByVal e _
      > As System.Windows. Forms.MouseEven tArgs) Handles MyBase.MouseMov e
      > Static LastCursor As Point
      > Dim NowCursor As Point = New Point(Cursor.Po sition.X,
      > Cursor.Position .Y)
      > If Point.op_Inequa lity(NowCursor, LastCursor) Then
      > If myMouseDown Then
      > Me.Location = New System.Drawing. Point(Cursor.Po sition.X _
      > - mouseX, Cursor.Position .Y - mouseY)
      > End If
      > LastCursor = Cursor.Position
      > End If
      > End Sub
      > Private Sub Form1_MouseUp(B yVal sender As Object, ByVal e As _
      > System.Windows. Forms.MouseEven tArgs) Handles MyBase.MouseUp
      > myMouseDown = False
      > End Sub
      > ///
      >
      >
      > "Lars Netzel" <[stop_spam]@host.topdomain >[color=green]
      > > Hi!
      > >
      > > I have a round area which I want to be able to move the mouse over and[/color]
      > fire[color=green]
      > > off events... how do I do that?
      > >
      > > I have drawn a FillPie Graphics and I feel that there has to be a way of
      > > getting to know if the mouse is over that area since I have the[/color]
      > coordinates[color=green]
      > > to paint the Pie but I don't know where to start or what to look for[/color]
      > really.[color=green]
      > >
      > > Best Regard
      > > /Lars
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • One Handed Man \( OHM - Terry Burns \)

        #4
        Re: Mouse Hover over round Area?

        No the answer is easier than that.


        You take the centre of the client area and compute.

        For example, if the radius is 10 your client area is 20,20. Then the
        centre point is 10,10. If x, or y is larger than the centre point + or -
        the mouse coordinates then this is out

        Alternatively calculate the hypotenuse for any given point


        H*H = A*A + O*O

        Once you calculate the H = SQRT( A*A + O*O) you can compare this against the
        Radius. to determin if the point is in.




        --

        OHM ( Terry Burns )
        . . . One-Handed-Man . . .
        If U Need My Email ,Ask Me

        Time flies when you don't know what you're doing

        "Lars Netzel" <[stop_spam]@host.topdomain > wrote in message
        news:O%23z$aT7n EHA.2948@TK2MSF TNGP11.phx.gbl. ..[color=blue]
        > Yes, it helps a little to understand how to get the posistion of the mouse
        > Cursor and compare with that op_Inequality but I'm not sure how to get the
        > position to compare with... I mean, if I have the mouseCursor.. Do I need[/color]
        to[color=blue]
        > loop thru all the points within the Round Area and run the op_inequality
        > test then, and how to I get the points for that Area...?
        >
        > /Lars
        >
        >
        >
        >
        >
        >
        > "Cor Ligthert" <notfirstname@p lanet.nl> skrev i meddelandet
        > news:uQzUO%236n EHA.1296@TK2MSF TNGP09.phx.gbl. ..[color=green]
        > > Lars,
        > >
        > > Did you ever see this nice sample I once have made in the past?
        > >
        > > It should have parts of your question.
        > > (it needs only a form and paste the code in)
        > >
        > > I hope you can use it?
        > >
        > > Cor
        > >
        > > \\\made by Cor Ligthert from ideas I got from Herfried. K. Wagner and[/color]
        > Fergus[color=green]
        > > Cooney
        > > Private WithEvents button1 As New Button
        > > Private mouseX, mouseY As Integer
        > > Private myMouseDown As Boolean
        > > Private Sub Form1_Load(ByVa l sender As System.Object, _
        > > ByVal e As System.EventArg s) Handles MyBase.Load
        > > Dim g As New System.Drawing. Drawing2D.Graph icsPath
        > > g.AddString("HT H" & vbCrLf & "Cor", _
        > > System.Drawing. FontFamily.Gene ricSansSerif, _
        > > System.Drawing. FontStyle.Bold, 200, _
        > > New Point(0, 0), _
        > > System.Drawing. StringFormat.Ge nericDefault)
        > > Me.BackColor = Color.Red
        > > Me.Region = New System.Drawing. Region(g)
        > > g.Dispose()
        > > Me.AutoScaleBas eSize = New System.Drawing. Size(0, 0)
        > > Me.ClientSize = New System.Drawing. Size(500, 450)
        > > button1.BackCol or =[/color][/color]
        System.Drawing. SystemColors.Ac tiveCaptionText[color=blue][color=green]
        > > button1.ForeCol or = System.Drawing. Color.Black
        > > button1.Locatio n = New System.Drawing. Point(425, 18)
        > > button1.Size = New System.Drawing. Size(20, 20)
        > > Me.Controls.Add (button1)
        > > button1.Text = "X"
        > > Me.Location = New System.Drawing. Point(50, 50)
        > > End Sub
        > > Private Sub Button1_Click(B yVal sender As Object, _
        > > ByVal e As System.EventArg s) Handles button1.Click
        > > Me.Close()
        > > End Sub
        > > Private Sub Form1_MouseDown (ByVal sender As Object, ByVal _
        > > e As System.Windows. Forms.MouseEven tArgs) Handles MyBase.MouseDow n
        > > myMouseDown = True
        > > mouseX = Cursor.Position .X - Me.Location.X
        > > mouseY = Cursor.Position .Y - Me.Location.Y
        > > End Sub
        > > Private Sub Form1_MouseMove (ByVal sender As Object, ByVal e _
        > > As System.Windows. Forms.MouseEven tArgs) Handles MyBase.MouseMov e
        > > Static LastCursor As Point
        > > Dim NowCursor As Point = New Point(Cursor.Po sition.X,
        > > Cursor.Position .Y)
        > > If Point.op_Inequa lity(NowCursor, LastCursor) Then
        > > If myMouseDown Then
        > > Me.Location = New System.Drawing. Point(Cursor.Po sition.X[/color][/color]
        _[color=blue][color=green]
        > > - mouseX, Cursor.Position .Y - mouseY)
        > > End If
        > > LastCursor = Cursor.Position
        > > End If
        > > End Sub
        > > Private Sub Form1_MouseUp(B yVal sender As Object, ByVal e As _
        > > System.Windows. Forms.MouseEven tArgs) Handles MyBase.MouseUp
        > > myMouseDown = False
        > > End Sub
        > > ///
        > >
        > >
        > > "Lars Netzel" <[stop_spam]@host.topdomain >[color=darkred]
        > > > Hi!
        > > >
        > > > I have a round area which I want to be able to move the mouse over and[/color]
        > > fire[color=darkred]
        > > > off events... how do I do that?
        > > >
        > > > I have drawn a FillPie Graphics and I feel that there has to be a way[/color][/color][/color]
        of[color=blue][color=green][color=darkred]
        > > > getting to know if the mouse is over that area since I have the[/color]
        > > coordinates[color=darkred]
        > > > to paint the Pie but I don't know where to start or what to look for[/color]
        > > really.[color=darkred]
        > > >
        > > > Best Regard
        > > > /Lars
        > > >
        > > >[/color]
        > >
        > >[/color]
        >
        >[/color]


        Comment

        • Ken Tucker [MVP]

          #5
          Re: Mouse Hover over round Area?

          Hi,

          Dim rgnCircle As Region

          Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
          System.EventArg s) Handles MyBase.Load

          Dim pth As New System.Drawing. Drawing2D.Graph icsPath

          pth.AddEllipse( 100, 100, 50, 50)

          rgnCircle = New Region(pth)

          End Sub

          Private Sub Form1_Paint(ByV al sender As Object, ByVal e As
          System.Windows. Forms.PaintEven tArgs) Handles MyBase.Paint

          e.Graphics.Fill Region(Brushes. Blue, rgnCircle)

          End Sub

          Private Sub Form1_MouseMove (ByVal sender As Object, ByVal e As
          System.Windows. Forms.MouseEven tArgs) Handles MyBase.MouseMov e

          Me.Text = String.Format(" In Circle {0}", rgnCircle.IsVis ible(New Point(e.X,
          e.Y)))

          End Sub



          Ken

          ---------------------------

          "Lars Netzel" <[stop_spam]@host.topdomain > wrote in message
          news:eF4Ja36nEH A.3988@tk2msftn gp13.phx.gbl...
          Hi!

          I have a round area which I want to be able to move the mouse over and fire
          off events... how do I do that?

          I have drawn a FillPie Graphics and I feel that there has to be a way of
          getting to know if the mouse is over that area since I have the coordinates
          to paint the Pie but I don't know where to start or what to look for really.

          Best Regard
          /Lars



          Comment

          • Ken Tucker [MVP]

            #6
            Re: Mouse Hover over round Area?

            Hi,

            Wouldnt region.isvisibl e be easier?




            Ken
            ---------------------
            "One Handed Man ( OHM - Terry Burns )" <news.microsoft .com> wrote in message
            news:uMRout7nEH A.3868@TK2MSFTN GP11.phx.gbl...
            No the answer is easier than that.


            You take the centre of the client area and compute.

            For example, if the radius is 10 your client area is 20,20. Then the
            centre point is 10,10. If x, or y is larger than the centre point + or -
            the mouse coordinates then this is out

            Alternatively calculate the hypotenuse for any given point


            H*H = A*A + O*O

            Once you calculate the H = SQRT( A*A + O*O) you can compare this against the
            Radius. to determin if the point is in.




            --

            OHM ( Terry Burns )
            . . . One-Handed-Man . . .
            If U Need My Email ,Ask Me

            Time flies when you don't know what you're doing

            "Lars Netzel" <[stop_spam]@host.topdomain > wrote in message
            news:O%23z$aT7n EHA.2948@TK2MSF TNGP11.phx.gbl. ..[color=blue]
            > Yes, it helps a little to understand how to get the posistion of the mouse
            > Cursor and compare with that op_Inequality but I'm not sure how to get the
            > position to compare with... I mean, if I have the mouseCursor.. Do I need[/color]
            to[color=blue]
            > loop thru all the points within the Round Area and run the op_inequality
            > test then, and how to I get the points for that Area...?
            >
            > /Lars
            >
            >
            >
            >
            >
            >
            > "Cor Ligthert" <notfirstname@p lanet.nl> skrev i meddelandet
            > news:uQzUO%236n EHA.1296@TK2MSF TNGP09.phx.gbl. ..[color=green]
            > > Lars,
            > >
            > > Did you ever see this nice sample I once have made in the past?
            > >
            > > It should have parts of your question.
            > > (it needs only a form and paste the code in)
            > >
            > > I hope you can use it?
            > >
            > > Cor
            > >
            > > \\\made by Cor Ligthert from ideas I got from Herfried. K. Wagner and[/color]
            > Fergus[color=green]
            > > Cooney
            > > Private WithEvents button1 As New Button
            > > Private mouseX, mouseY As Integer
            > > Private myMouseDown As Boolean
            > > Private Sub Form1_Load(ByVa l sender As System.Object, _
            > > ByVal e As System.EventArg s) Handles MyBase.Load
            > > Dim g As New System.Drawing. Drawing2D.Graph icsPath
            > > g.AddString("HT H" & vbCrLf & "Cor", _
            > > System.Drawing. FontFamily.Gene ricSansSerif, _
            > > System.Drawing. FontStyle.Bold, 200, _
            > > New Point(0, 0), _
            > > System.Drawing. StringFormat.Ge nericDefault)
            > > Me.BackColor = Color.Red
            > > Me.Region = New System.Drawing. Region(g)
            > > g.Dispose()
            > > Me.AutoScaleBas eSize = New System.Drawing. Size(0, 0)
            > > Me.ClientSize = New System.Drawing. Size(500, 450)
            > > button1.BackCol or =[/color][/color]
            System.Drawing. SystemColors.Ac tiveCaptionText[color=blue][color=green]
            > > button1.ForeCol or = System.Drawing. Color.Black
            > > button1.Locatio n = New System.Drawing. Point(425, 18)
            > > button1.Size = New System.Drawing. Size(20, 20)
            > > Me.Controls.Add (button1)
            > > button1.Text = "X"
            > > Me.Location = New System.Drawing. Point(50, 50)
            > > End Sub
            > > Private Sub Button1_Click(B yVal sender As Object, _
            > > ByVal e As System.EventArg s) Handles button1.Click
            > > Me.Close()
            > > End Sub
            > > Private Sub Form1_MouseDown (ByVal sender As Object, ByVal _
            > > e As System.Windows. Forms.MouseEven tArgs) Handles MyBase.MouseDow n
            > > myMouseDown = True
            > > mouseX = Cursor.Position .X - Me.Location.X
            > > mouseY = Cursor.Position .Y - Me.Location.Y
            > > End Sub
            > > Private Sub Form1_MouseMove (ByVal sender As Object, ByVal e _
            > > As System.Windows. Forms.MouseEven tArgs) Handles MyBase.MouseMov e
            > > Static LastCursor As Point
            > > Dim NowCursor As Point = New Point(Cursor.Po sition.X,
            > > Cursor.Position .Y)
            > > If Point.op_Inequa lity(NowCursor, LastCursor) Then
            > > If myMouseDown Then
            > > Me.Location = New System.Drawing. Point(Cursor.Po sition.X[/color][/color]
            _[color=blue][color=green]
            > > - mouseX, Cursor.Position .Y - mouseY)
            > > End If
            > > LastCursor = Cursor.Position
            > > End If
            > > End Sub
            > > Private Sub Form1_MouseUp(B yVal sender As Object, ByVal e As _
            > > System.Windows. Forms.MouseEven tArgs) Handles MyBase.MouseUp
            > > myMouseDown = False
            > > End Sub
            > > ///
            > >
            > >
            > > "Lars Netzel" <[stop_spam]@host.topdomain >[color=darkred]
            > > > Hi!
            > > >
            > > > I have a round area which I want to be able to move the mouse over and[/color]
            > > fire[color=darkred]
            > > > off events... how do I do that?
            > > >
            > > > I have drawn a FillPie Graphics and I feel that there has to be a way[/color][/color][/color]
            of[color=blue][color=green][color=darkred]
            > > > getting to know if the mouse is over that area since I have the[/color]
            > > coordinates[color=darkred]
            > > > to paint the Pie but I don't know where to start or what to look for[/color]
            > > really.[color=darkred]
            > > >
            > > > Best Regard
            > > > /Lars
            > > >
            > > >[/color]
            > >
            > >[/color]
            >
            >[/color]



            Comment

            • One Handed Man \( OHM - Terry Burns \)

              #7
              Re: Mouse Hover over round Area?

              I tested this , it may not be the most efficient, but it works

              Private cp As Point

              Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
              System.EventArg s) Handles Button1.Click
              Dim g As Graphics

              g = pBox.CreateGrap hics

              cp = New Point(pBox.Size .Width / 2, pBox.Size.Heigh t / 2)

              g.DrawEllipse(N ew Pen(Color.Red), New Rectangle(cp.X - 10, cp.Y -
              10, 20, 20))



              End Sub

              Private Sub pBox_MouseMove( ByVal sender As Object, ByVal e As
              System.Windows. Forms.MouseEven tArgs) Handles pBox.MouseMove

              Dim rx As Single = 10
              Dim ry As Single = 10
              Dim distance As Single 'between centre and mouse position
              Dim a, h, o As Single

              If e.X = cp.X And e.Y = cp.Y Then ' Same Point
              distance = 0
              ElseIf e.X = cp.X Then 'Horizontal line
              distance = Math.Abs(e.X - cp.X)
              ElseIf e.Y = cp.Y Then 'Virtical Line
              distance = Math.Abs(e.Y - cp.Y)
              Else 'This is a triangle, so calculate the hypotenuse
              a = Math.Abs(e.X - cp.X)
              o = Math.Abs(e.Y - cp.Y)
              h = Math.Sqrt(a ^ 2 + o ^ 2)
              distance = h
              End If
              'Debug.WriteLin e("Distance : " & distance & " : " & cp.ToString)
              If distance < 10 Then ' this is inside the circle so
              Debug.WriteLine (e.X & " : " & e.Y)
              End If

              End Sub

              --

              OHM ( Terry Burns )
              . . . One-Handed-Man . . .
              If U Need My Email ,Ask Me

              Time flies when you don't know what you're doing

              "Lars Netzel" <[stop_spam]@host.topdomain > wrote in message
              news:O%23z$aT7n EHA.2948@TK2MSF TNGP11.phx.gbl. ..[color=blue]
              > Yes, it helps a little to understand how to get the posistion of the mouse
              > Cursor and compare with that op_Inequality but I'm not sure how to get the
              > position to compare with... I mean, if I have the mouseCursor.. Do I need[/color]
              to[color=blue]
              > loop thru all the points within the Round Area and run the op_inequality
              > test then, and how to I get the points for that Area...?
              >
              > /Lars
              >
              >
              >
              >
              >
              >
              > "Cor Ligthert" <notfirstname@p lanet.nl> skrev i meddelandet
              > news:uQzUO%236n EHA.1296@TK2MSF TNGP09.phx.gbl. ..[color=green]
              > > Lars,
              > >
              > > Did you ever see this nice sample I once have made in the past?
              > >
              > > It should have parts of your question.
              > > (it needs only a form and paste the code in)
              > >
              > > I hope you can use it?
              > >
              > > Cor
              > >
              > > \\\made by Cor Ligthert from ideas I got from Herfried. K. Wagner and[/color]
              > Fergus[color=green]
              > > Cooney
              > > Private WithEvents button1 As New Button
              > > Private mouseX, mouseY As Integer
              > > Private myMouseDown As Boolean
              > > Private Sub Form1_Load(ByVa l sender As System.Object, _
              > > ByVal e As System.EventArg s) Handles MyBase.Load
              > > Dim g As New System.Drawing. Drawing2D.Graph icsPath
              > > g.AddString("HT H" & vbCrLf & "Cor", _
              > > System.Drawing. FontFamily.Gene ricSansSerif, _
              > > System.Drawing. FontStyle.Bold, 200, _
              > > New Point(0, 0), _
              > > System.Drawing. StringFormat.Ge nericDefault)
              > > Me.BackColor = Color.Red
              > > Me.Region = New System.Drawing. Region(g)
              > > g.Dispose()
              > > Me.AutoScaleBas eSize = New System.Drawing. Size(0, 0)
              > > Me.ClientSize = New System.Drawing. Size(500, 450)
              > > button1.BackCol or =[/color][/color]
              System.Drawing. SystemColors.Ac tiveCaptionText[color=blue][color=green]
              > > button1.ForeCol or = System.Drawing. Color.Black
              > > button1.Locatio n = New System.Drawing. Point(425, 18)
              > > button1.Size = New System.Drawing. Size(20, 20)
              > > Me.Controls.Add (button1)
              > > button1.Text = "X"
              > > Me.Location = New System.Drawing. Point(50, 50)
              > > End Sub
              > > Private Sub Button1_Click(B yVal sender As Object, _
              > > ByVal e As System.EventArg s) Handles button1.Click
              > > Me.Close()
              > > End Sub
              > > Private Sub Form1_MouseDown (ByVal sender As Object, ByVal _
              > > e As System.Windows. Forms.MouseEven tArgs) Handles MyBase.MouseDow n
              > > myMouseDown = True
              > > mouseX = Cursor.Position .X - Me.Location.X
              > > mouseY = Cursor.Position .Y - Me.Location.Y
              > > End Sub
              > > Private Sub Form1_MouseMove (ByVal sender As Object, ByVal e _
              > > As System.Windows. Forms.MouseEven tArgs) Handles MyBase.MouseMov e
              > > Static LastCursor As Point
              > > Dim NowCursor As Point = New Point(Cursor.Po sition.X,
              > > Cursor.Position .Y)
              > > If Point.op_Inequa lity(NowCursor, LastCursor) Then
              > > If myMouseDown Then
              > > Me.Location = New System.Drawing. Point(Cursor.Po sition.X[/color][/color]
              _[color=blue][color=green]
              > > - mouseX, Cursor.Position .Y - mouseY)
              > > End If
              > > LastCursor = Cursor.Position
              > > End If
              > > End Sub
              > > Private Sub Form1_MouseUp(B yVal sender As Object, ByVal e As _
              > > System.Windows. Forms.MouseEven tArgs) Handles MyBase.MouseUp
              > > myMouseDown = False
              > > End Sub
              > > ///
              > >
              > >
              > > "Lars Netzel" <[stop_spam]@host.topdomain >[color=darkred]
              > > > Hi!
              > > >
              > > > I have a round area which I want to be able to move the mouse over and[/color]
              > > fire[color=darkred]
              > > > off events... how do I do that?
              > > >
              > > > I have drawn a FillPie Graphics and I feel that there has to be a way[/color][/color][/color]
              of[color=blue][color=green][color=darkred]
              > > > getting to know if the mouse is over that area since I have the[/color]
              > > coordinates[color=darkred]
              > > > to paint the Pie but I don't know where to start or what to look for[/color]
              > > really.[color=darkred]
              > > >
              > > > Best Regard
              > > > /Lars
              > > >
              > > >[/color]
              > >
              > >[/color]
              >
              >[/color]


              Comment

              • One Handed Man \( OHM - Terry Burns \)

                #8
                Re: Mouse Hover over round Area?

                Yes but this is a circle, what you refer to is a rectangle test. I think the
                OP wanted to only fire events or trigger action at least when the mouse was
                inside a defined pie chart or ( circle )

                --

                OHM ( Terry Burns )
                . . . One-Handed-Man . . .
                If U Need My Email ,Ask Me

                Time flies when you don't know what you're doing

                "Ken Tucker [MVP]" <vb2ae@bellsout h.net> wrote in message
                news:euDzHg8nEH A.2840@TK2MSFTN GP10.phx.gbl...[color=blue]
                > Hi,
                >
                > Wouldnt region.isvisibl e be easier?
                >
                >[/color]
                http://msdn.microsoft.com/library/de...sibletopic.asp[color=blue]
                >
                >
                > Ken
                > ---------------------
                > "One Handed Man ( OHM - Terry Burns )" <news.microsoft .com> wrote in[/color]
                message[color=blue]
                > news:uMRout7nEH A.3868@TK2MSFTN GP11.phx.gbl...
                > No the answer is easier than that.
                >
                >
                > You take the centre of the client area and compute.
                >
                > For example, if the radius is 10 your client area is 20,20. Then the
                > centre point is 10,10. If x, or y is larger than the centre point + or -
                > the mouse coordinates then this is out
                >
                > Alternatively calculate the hypotenuse for any given point
                >
                >
                > H*H = A*A + O*O
                >
                > Once you calculate the H = SQRT( A*A + O*O) you can compare this against[/color]
                the[color=blue]
                > Radius. to determin if the point is in.
                >
                >
                >
                >
                > --
                >
                > OHM ( Terry Burns )
                > . . . One-Handed-Man . . .
                > If U Need My Email ,Ask Me
                >
                > Time flies when you don't know what you're doing
                >
                > "Lars Netzel" <[stop_spam]@host.topdomain > wrote in message
                > news:O%23z$aT7n EHA.2948@TK2MSF TNGP11.phx.gbl. ..[color=green]
                > > Yes, it helps a little to understand how to get the posistion of the[/color][/color]
                mouse[color=blue][color=green]
                > > Cursor and compare with that op_Inequality but I'm not sure how to get[/color][/color]
                the[color=blue][color=green]
                > > position to compare with... I mean, if I have the mouseCursor.. Do I[/color][/color]
                need[color=blue]
                > to[color=green]
                > > loop thru all the points within the Round Area and run the op_inequality
                > > test then, and how to I get the points for that Area...?
                > >
                > > /Lars
                > >
                > >
                > >
                > >
                > >
                > >
                > > "Cor Ligthert" <notfirstname@p lanet.nl> skrev i meddelandet
                > > news:uQzUO%236n EHA.1296@TK2MSF TNGP09.phx.gbl. ..[color=darkred]
                > > > Lars,
                > > >
                > > > Did you ever see this nice sample I once have made in the past?
                > > >
                > > > It should have parts of your question.
                > > > (it needs only a form and paste the code in)
                > > >
                > > > I hope you can use it?
                > > >
                > > > Cor
                > > >
                > > > \\\made by Cor Ligthert from ideas I got from Herfried. K. Wagner and[/color]
                > > Fergus[color=darkred]
                > > > Cooney
                > > > Private WithEvents button1 As New Button
                > > > Private mouseX, mouseY As Integer
                > > > Private myMouseDown As Boolean
                > > > Private Sub Form1_Load(ByVa l sender As System.Object, _
                > > > ByVal e As System.EventArg s) Handles MyBase.Load
                > > > Dim g As New System.Drawing. Drawing2D.Graph icsPath
                > > > g.AddString("HT H" & vbCrLf & "Cor", _
                > > > System.Drawing. FontFamily.Gene ricSansSerif, _
                > > > System.Drawing. FontStyle.Bold, 200, _
                > > > New Point(0, 0), _
                > > > System.Drawing. StringFormat.Ge nericDefault)
                > > > Me.BackColor = Color.Red
                > > > Me.Region = New System.Drawing. Region(g)
                > > > g.Dispose()
                > > > Me.AutoScaleBas eSize = New System.Drawing. Size(0, 0)
                > > > Me.ClientSize = New System.Drawing. Size(500, 450)
                > > > button1.BackCol or =[/color][/color]
                > System.Drawing. SystemColors.Ac tiveCaptionText[color=green][color=darkred]
                > > > button1.ForeCol or = System.Drawing. Color.Black
                > > > button1.Locatio n = New System.Drawing. Point(425, 18)
                > > > button1.Size = New System.Drawing. Size(20, 20)
                > > > Me.Controls.Add (button1)
                > > > button1.Text = "X"
                > > > Me.Location = New System.Drawing. Point(50, 50)
                > > > End Sub
                > > > Private Sub Button1_Click(B yVal sender As Object, _
                > > > ByVal e As System.EventArg s) Handles button1.Click
                > > > Me.Close()
                > > > End Sub
                > > > Private Sub Form1_MouseDown (ByVal sender As Object, ByVal _
                > > > e As System.Windows. Forms.MouseEven tArgs) Handles MyBase.MouseDow n
                > > > myMouseDown = True
                > > > mouseX = Cursor.Position .X - Me.Location.X
                > > > mouseY = Cursor.Position .Y - Me.Location.Y
                > > > End Sub
                > > > Private Sub Form1_MouseMove (ByVal sender As Object, ByVal e _
                > > > As System.Windows. Forms.MouseEven tArgs) Handles MyBase.MouseMov e
                > > > Static LastCursor As Point
                > > > Dim NowCursor As Point = New Point(Cursor.Po sition.X,
                > > > Cursor.Position .Y)
                > > > If Point.op_Inequa lity(NowCursor, LastCursor) Then
                > > > If myMouseDown Then
                > > > Me.Location = New[/color][/color][/color]
                System.Drawing. Point(Cursor.Po sition.X[color=blue]
                > _[color=green][color=darkred]
                > > > - mouseX, Cursor.Position .Y - mouseY)
                > > > End If
                > > > LastCursor = Cursor.Position
                > > > End If
                > > > End Sub
                > > > Private Sub Form1_MouseUp(B yVal sender As Object, ByVal e As _
                > > > System.Windows. Forms.MouseEven tArgs) Handles MyBase.MouseUp
                > > > myMouseDown = False
                > > > End Sub
                > > > ///
                > > >
                > > >
                > > > "Lars Netzel" <[stop_spam]@host.topdomain >
                > > > > Hi!
                > > > >
                > > > > I have a round area which I want to be able to move the mouse over[/color][/color][/color]
                and[color=blue][color=green][color=darkred]
                > > > fire
                > > > > off events... how do I do that?
                > > > >
                > > > > I have drawn a FillPie Graphics and I feel that there has to be a[/color][/color][/color]
                way[color=blue]
                > of[color=green][color=darkred]
                > > > > getting to know if the mouse is over that area since I have the
                > > > coordinates
                > > > > to paint the Pie but I don't know where to start or what to look for
                > > > really.
                > > > >
                > > > > Best Regard
                > > > > /Lars
                > > > >
                > > > >
                > > >
                > > >[/color]
                > >
                > >[/color]
                >
                >
                >[/color]


                Comment

                • Lars Netzel

                  #9
                  Re: Mouse Hover over round Area?

                  Thanx.. I'm getting closer, I do have some problems with the whole
                  calculation though but my question is answered... I know how to actually do
                  the checks, where to put the code and stuff, I just need to get the
                  calculations right now.

                  So once again, I'm grateful!

                  /Lars


                  "One Handed Man ( OHM - Terry Burns )" <news.microsoft .com> skrev i
                  meddelandet news:uMRout7nEH A.3868@TK2MSFTN GP11.phx.gbl...[color=blue]
                  > No the answer is easier than that.
                  >
                  >
                  > You take the centre of the client area and compute.
                  >
                  > For example, if the radius is 10 your client area is 20,20. Then the
                  > centre point is 10,10. If x, or y is larger than the centre point + or -
                  > the mouse coordinates then this is out
                  >
                  > Alternatively calculate the hypotenuse for any given point
                  >
                  >
                  > H*H = A*A + O*O
                  >
                  > Once you calculate the H = SQRT( A*A + O*O) you can compare this against[/color]
                  the[color=blue]
                  > Radius. to determin if the point is in.
                  >
                  >
                  >
                  >
                  > --
                  >
                  > OHM ( Terry Burns )
                  > . . . One-Handed-Man . . .
                  > If U Need My Email ,Ask Me
                  >
                  > Time flies when you don't know what you're doing
                  >
                  > "Lars Netzel" <[stop_spam]@host.topdomain > wrote in message
                  > news:O%23z$aT7n EHA.2948@TK2MSF TNGP11.phx.gbl. ..[color=green]
                  > > Yes, it helps a little to understand how to get the posistion of the[/color][/color]
                  mouse[color=blue][color=green]
                  > > Cursor and compare with that op_Inequality but I'm not sure how to get[/color][/color]
                  the[color=blue][color=green]
                  > > position to compare with... I mean, if I have the mouseCursor.. Do I[/color][/color]
                  need[color=blue]
                  > to[color=green]
                  > > loop thru all the points within the Round Area and run the op_inequality
                  > > test then, and how to I get the points for that Area...?
                  > >
                  > > /Lars
                  > >
                  > >
                  > >
                  > >
                  > >
                  > >
                  > > "Cor Ligthert" <notfirstname@p lanet.nl> skrev i meddelandet
                  > > news:uQzUO%236n EHA.1296@TK2MSF TNGP09.phx.gbl. ..[color=darkred]
                  > > > Lars,
                  > > >
                  > > > Did you ever see this nice sample I once have made in the past?
                  > > >
                  > > > It should have parts of your question.
                  > > > (it needs only a form and paste the code in)
                  > > >
                  > > > I hope you can use it?
                  > > >
                  > > > Cor
                  > > >
                  > > > \\\made by Cor Ligthert from ideas I got from Herfried. K. Wagner and[/color]
                  > > Fergus[color=darkred]
                  > > > Cooney
                  > > > Private WithEvents button1 As New Button
                  > > > Private mouseX, mouseY As Integer
                  > > > Private myMouseDown As Boolean
                  > > > Private Sub Form1_Load(ByVa l sender As System.Object, _
                  > > > ByVal e As System.EventArg s) Handles MyBase.Load
                  > > > Dim g As New System.Drawing. Drawing2D.Graph icsPath
                  > > > g.AddString("HT H" & vbCrLf & "Cor", _
                  > > > System.Drawing. FontFamily.Gene ricSansSerif, _
                  > > > System.Drawing. FontStyle.Bold, 200, _
                  > > > New Point(0, 0), _
                  > > > System.Drawing. StringFormat.Ge nericDefault)
                  > > > Me.BackColor = Color.Red
                  > > > Me.Region = New System.Drawing. Region(g)
                  > > > g.Dispose()
                  > > > Me.AutoScaleBas eSize = New System.Drawing. Size(0, 0)
                  > > > Me.ClientSize = New System.Drawing. Size(500, 450)
                  > > > button1.BackCol or =[/color][/color]
                  > System.Drawing. SystemColors.Ac tiveCaptionText[color=green][color=darkred]
                  > > > button1.ForeCol or = System.Drawing. Color.Black
                  > > > button1.Locatio n = New System.Drawing. Point(425, 18)
                  > > > button1.Size = New System.Drawing. Size(20, 20)
                  > > > Me.Controls.Add (button1)
                  > > > button1.Text = "X"
                  > > > Me.Location = New System.Drawing. Point(50, 50)
                  > > > End Sub
                  > > > Private Sub Button1_Click(B yVal sender As Object, _
                  > > > ByVal e As System.EventArg s) Handles button1.Click
                  > > > Me.Close()
                  > > > End Sub
                  > > > Private Sub Form1_MouseDown (ByVal sender As Object, ByVal _
                  > > > e As System.Windows. Forms.MouseEven tArgs) Handles MyBase.MouseDow n
                  > > > myMouseDown = True
                  > > > mouseX = Cursor.Position .X - Me.Location.X
                  > > > mouseY = Cursor.Position .Y - Me.Location.Y
                  > > > End Sub
                  > > > Private Sub Form1_MouseMove (ByVal sender As Object, ByVal e _
                  > > > As System.Windows. Forms.MouseEven tArgs) Handles MyBase.MouseMov e
                  > > > Static LastCursor As Point
                  > > > Dim NowCursor As Point = New Point(Cursor.Po sition.X,
                  > > > Cursor.Position .Y)
                  > > > If Point.op_Inequa lity(NowCursor, LastCursor) Then
                  > > > If myMouseDown Then
                  > > > Me.Location = New[/color][/color][/color]
                  System.Drawing. Point(Cursor.Po sition.X[color=blue]
                  > _[color=green][color=darkred]
                  > > > - mouseX, Cursor.Position .Y - mouseY)
                  > > > End If
                  > > > LastCursor = Cursor.Position
                  > > > End If
                  > > > End Sub
                  > > > Private Sub Form1_MouseUp(B yVal sender As Object, ByVal e As _
                  > > > System.Windows. Forms.MouseEven tArgs) Handles MyBase.MouseUp
                  > > > myMouseDown = False
                  > > > End Sub
                  > > > ///
                  > > >
                  > > >
                  > > > "Lars Netzel" <[stop_spam]@host.topdomain >
                  > > > > Hi!
                  > > > >
                  > > > > I have a round area which I want to be able to move the mouse over[/color][/color][/color]
                  and[color=blue][color=green][color=darkred]
                  > > > fire
                  > > > > off events... how do I do that?
                  > > > >
                  > > > > I have drawn a FillPie Graphics and I feel that there has to be a[/color][/color][/color]
                  way[color=blue]
                  > of[color=green][color=darkred]
                  > > > > getting to know if the mouse is over that area since I have the
                  > > > coordinates
                  > > > > to paint the Pie but I don't know where to start or what to look for
                  > > > really.
                  > > > >
                  > > > > Best Regard
                  > > > > /Lars
                  > > > >
                  > > > >
                  > > >
                  > > >[/color]
                  > >
                  > >[/color]
                  >
                  >[/color]


                  Comment

                  • Jay B. Harlow [MVP - Outlook]

                    #10
                    Re: Mouse Hover over round Area?

                    OHM,
                    But a Region (GraphicsPath really) can be circular!

                    Dim path As New System.Drawing. Drawing2D.Graph icsPath()
                    path.AddEllipse (aRectangle)


                    So you could use either Region.IsVisibl e or GraphicsPath.Is Visible.

                    Borrowing your earlier code (untested):
                    [color=blue]
                    > Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
                    > System.EventArg s) Handles Button1.Click
                    > Dim g As Graphics
                    >
                    > g = pBox.CreateGrap hics
                    >
                    > cp = New Point(pBox.Size .Width / 2, pBox.Size.Heigh t / 2)
                    >
                    > g.DrawEllipse(N ew Pen(Color.Red), New Rectangle(cp.X - 10, cp.Y -
                    > 10, 20, 20))
                    >
                    >
                    >
                    > End Sub
                    >
                    > Private Sub pBox_MouseMove( ByVal sender As Object, ByVal e As
                    > System.Windows. Forms.MouseEven tArgs) Handles pBox.MouseMove
                    >[/color]
                    Dim path As New System.Drawing. Drawing2D.Graph icsPath
                    Dim cp As New Point(pBox.Size .Width / 2, pBox.Size.Heigh t / 2)

                    path.AddEllipse (New Rectangle(cp.X - 10, cp.Y - 10, 20, 20))

                    If path.IsVisible( e.X, e.Y) Then

                    Debug.WriteLine (e.X & " : " & e.Y)

                    End If
                    [color=blue]
                    >
                    > End Sub[/color]


                    I would probably keep a class instance variable for the outline of the image
                    being checked, the GraphicsPath above, then I would simply use this variable
                    in the MouseMove & Paint events. Depending on what the "area" is really that
                    the OP is wanting I would consider creating a derived control & set its
                    Control.Region property to the shape desired (a round Button or round Label
                    for example).

                    Hope this helps
                    Jay

                    "One Handed Man ( OHM - Terry Burns )" <news.microsoft .com> wrote in message
                    news:%23oVJWL9n EHA.3428@TK2MSF TNGP11.phx.gbl. ..[color=blue]
                    > Yes but this is a circle, what you refer to is a rectangle test. I think
                    > the
                    > OP wanted to only fire events or trigger action at least when the mouse
                    > was
                    > inside a defined pie chart or ( circle )
                    >
                    > --
                    >
                    > OHM ( Terry Burns )
                    > . . . One-Handed-Man . . .
                    > If U Need My Email ,Ask Me
                    >
                    > Time flies when you don't know what you're doing
                    >
                    > "Ken Tucker [MVP]" <vb2ae@bellsout h.net> wrote in message
                    > news:euDzHg8nEH A.2840@TK2MSFTN GP10.phx.gbl...[color=green]
                    >> Hi,
                    >>
                    >> Wouldnt region.isvisibl e be easier?
                    >>
                    >>[/color]
                    > http://msdn.microsoft.com/library/de...sibletopic.asp[color=green]
                    >>
                    >>
                    >> Ken
                    >> ---------------------
                    >> "One Handed Man ( OHM - Terry Burns )" <news.microsoft .com> wrote in[/color]
                    > message[color=green]
                    >> news:uMRout7nEH A.3868@TK2MSFTN GP11.phx.gbl...
                    >> No the answer is easier than that.
                    >>
                    >>
                    >> You take the centre of the client area and compute.
                    >>
                    >> For example, if the radius is 10 your client area is 20,20. Then the
                    >> centre point is 10,10. If x, or y is larger than the centre point +
                    >> or -
                    >> the mouse coordinates then this is out
                    >>
                    >> Alternatively calculate the hypotenuse for any given point
                    >>
                    >>
                    >> H*H = A*A + O*O
                    >>
                    >> Once you calculate the H = SQRT( A*A + O*O) you can compare this against[/color]
                    > the[color=green]
                    >> Radius. to determin if the point is in.
                    >>
                    >>
                    >>
                    >>
                    >> --
                    >>
                    >> OHM ( Terry Burns )
                    >> . . . One-Handed-Man . . .
                    >> If U Need My Email ,Ask Me
                    >>
                    >> Time flies when you don't know what you're doing
                    >>
                    >> "Lars Netzel" <[stop_spam]@host.topdomain > wrote in message
                    >> news:O%23z$aT7n EHA.2948@TK2MSF TNGP11.phx.gbl. ..[color=darkred]
                    >> > Yes, it helps a little to understand how to get the posistion of the[/color][/color]
                    > mouse[color=green][color=darkred]
                    >> > Cursor and compare with that op_Inequality but I'm not sure how to get[/color][/color]
                    > the[color=green][color=darkred]
                    >> > position to compare with... I mean, if I have the mouseCursor.. Do I[/color][/color]
                    > need[color=green]
                    >> to[color=darkred]
                    >> > loop thru all the points within the Round Area and run the
                    >> > op_inequality
                    >> > test then, and how to I get the points for that Area...?
                    >> >
                    >> > /Lars
                    >> >
                    >> >
                    >> >
                    >> >
                    >> >
                    >> >
                    >> > "Cor Ligthert" <notfirstname@p lanet.nl> skrev i meddelandet
                    >> > news:uQzUO%236n EHA.1296@TK2MSF TNGP09.phx.gbl. ..
                    >> > > Lars,
                    >> > >
                    >> > > Did you ever see this nice sample I once have made in the past?
                    >> > >
                    >> > > It should have parts of your question.
                    >> > > (it needs only a form and paste the code in)
                    >> > >
                    >> > > I hope you can use it?
                    >> > >
                    >> > > Cor
                    >> > >
                    >> > > \\\made by Cor Ligthert from ideas I got from Herfried. K. Wagner and
                    >> > Fergus
                    >> > > Cooney
                    >> > > Private WithEvents button1 As New Button
                    >> > > Private mouseX, mouseY As Integer
                    >> > > Private myMouseDown As Boolean
                    >> > > Private Sub Form1_Load(ByVa l sender As System.Object, _
                    >> > > ByVal e As System.EventArg s) Handles MyBase.Load
                    >> > > Dim g As New System.Drawing. Drawing2D.Graph icsPath
                    >> > > g.AddString("HT H" & vbCrLf & "Cor", _
                    >> > > System.Drawing. FontFamily.Gene ricSansSerif, _
                    >> > > System.Drawing. FontStyle.Bold, 200, _
                    >> > > New Point(0, 0), _
                    >> > > System.Drawing. StringFormat.Ge nericDefault)
                    >> > > Me.BackColor = Color.Red
                    >> > > Me.Region = New System.Drawing. Region(g)
                    >> > > g.Dispose()
                    >> > > Me.AutoScaleBas eSize = New System.Drawing. Size(0, 0)
                    >> > > Me.ClientSize = New System.Drawing. Size(500, 450)
                    >> > > button1.BackCol or =[/color]
                    >> System.Drawing. SystemColors.Ac tiveCaptionText[color=darkred]
                    >> > > button1.ForeCol or = System.Drawing. Color.Black
                    >> > > button1.Locatio n = New System.Drawing. Point(425, 18)
                    >> > > button1.Size = New System.Drawing. Size(20, 20)
                    >> > > Me.Controls.Add (button1)
                    >> > > button1.Text = "X"
                    >> > > Me.Location = New System.Drawing. Point(50, 50)
                    >> > > End Sub
                    >> > > Private Sub Button1_Click(B yVal sender As Object, _
                    >> > > ByVal e As System.EventArg s) Handles button1.Click
                    >> > > Me.Close()
                    >> > > End Sub
                    >> > > Private Sub Form1_MouseDown (ByVal sender As Object, ByVal _
                    >> > > e As System.Windows. Forms.MouseEven tArgs) Handles
                    >> > > MyBase.MouseDow n
                    >> > > myMouseDown = True
                    >> > > mouseX = Cursor.Position .X - Me.Location.X
                    >> > > mouseY = Cursor.Position .Y - Me.Location.Y
                    >> > > End Sub
                    >> > > Private Sub Form1_MouseMove (ByVal sender As Object, ByVal e _
                    >> > > As System.Windows. Forms.MouseEven tArgs) Handles MyBase.MouseMov e
                    >> > > Static LastCursor As Point
                    >> > > Dim NowCursor As Point = New Point(Cursor.Po sition.X,
                    >> > > Cursor.Position .Y)
                    >> > > If Point.op_Inequa lity(NowCursor, LastCursor) Then
                    >> > > If myMouseDown Then
                    >> > > Me.Location = New[/color][/color]
                    > System.Drawing. Point(Cursor.Po sition.X[color=green]
                    >> _[color=darkred]
                    >> > > - mouseX, Cursor.Position .Y - mouseY)
                    >> > > End If
                    >> > > LastCursor = Cursor.Position
                    >> > > End If
                    >> > > End Sub
                    >> > > Private Sub Form1_MouseUp(B yVal sender As Object, ByVal e As _
                    >> > > System.Windows. Forms.MouseEven tArgs) Handles MyBase.MouseUp
                    >> > > myMouseDown = False
                    >> > > End Sub
                    >> > > ///
                    >> > >
                    >> > >
                    >> > > "Lars Netzel" <[stop_spam]@host.topdomain >
                    >> > > > Hi!
                    >> > > >
                    >> > > > I have a round area which I want to be able to move the mouse over[/color][/color]
                    > and[color=green][color=darkred]
                    >> > > fire
                    >> > > > off events... how do I do that?
                    >> > > >
                    >> > > > I have drawn a FillPie Graphics and I feel that there has to be a[/color][/color]
                    > way[color=green]
                    >> of[color=darkred]
                    >> > > > getting to know if the mouse is over that area since I have the
                    >> > > coordinates
                    >> > > > to paint the Pie but I don't know where to start or what to look
                    >> > > > for
                    >> > > really.
                    >> > > >
                    >> > > > Best Regard
                    >> > > > /Lars
                    >> > > >
                    >> > > >
                    >> > >
                    >> > >
                    >> >
                    >> >[/color]
                    >>
                    >>
                    >>[/color]
                    >
                    >[/color]


                    Comment

                    • One Handed Man \( OHM - Terry Burns \)

                      #11
                      Re: Mouse Hover over round Area?

                      Good stuff !, thats illuminating, its allways good to learn something new.!

                      Thanks

                      --

                      OHM ( Terry Burns )
                      . . . One-Handed-Man . . .
                      If U Need My Email ,Ask Me

                      Time flies when you don't know what you're doing

                      "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP @msn.com> wrote in message
                      news:etPFJA%23n EHA.3392@TK2MSF TNGP15.phx.gbl. ..[color=blue]
                      > OHM,
                      > But a Region (GraphicsPath really) can be circular!
                      >
                      > Dim path As New System.Drawing. Drawing2D.Graph icsPath()
                      > path.AddEllipse (aRectangle)
                      >
                      >
                      > So you could use either Region.IsVisibl e or GraphicsPath.Is Visible.
                      >
                      > Borrowing your earlier code (untested):
                      >[color=green]
                      > > Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
                      > > System.EventArg s) Handles Button1.Click
                      > > Dim g As Graphics
                      > >
                      > > g = pBox.CreateGrap hics
                      > >
                      > > cp = New Point(pBox.Size .Width / 2, pBox.Size.Heigh t / 2)
                      > >
                      > > g.DrawEllipse(N ew Pen(Color.Red), New Rectangle(cp.X - 10, cp.Y -
                      > > 10, 20, 20))
                      > >
                      > >
                      > >
                      > > End Sub
                      > >
                      > > Private Sub pBox_MouseMove( ByVal sender As Object, ByVal e As
                      > > System.Windows. Forms.MouseEven tArgs) Handles pBox.MouseMove
                      > >[/color]
                      > Dim path As New System.Drawing. Drawing2D.Graph icsPath
                      > Dim cp As New Point(pBox.Size .Width / 2, pBox.Size.Heigh t / 2)
                      >
                      > path.AddEllipse (New Rectangle(cp.X - 10, cp.Y - 10, 20, 20))
                      >
                      > If path.IsVisible( e.X, e.Y) Then
                      >
                      > Debug.WriteLine (e.X & " : " & e.Y)
                      >
                      > End If
                      >[color=green]
                      > >
                      > > End Sub[/color]
                      >
                      >
                      > I would probably keep a class instance variable for the outline of the[/color]
                      image[color=blue]
                      > being checked, the GraphicsPath above, then I would simply use this[/color]
                      variable[color=blue]
                      > in the MouseMove & Paint events. Depending on what the "area" is really[/color]
                      that[color=blue]
                      > the OP is wanting I would consider creating a derived control & set its
                      > Control.Region property to the shape desired (a round Button or round[/color]
                      Label[color=blue]
                      > for example).
                      >
                      > Hope this helps
                      > Jay
                      >
                      > "One Handed Man ( OHM - Terry Burns )" <news.microsoft .com> wrote in[/color]
                      message[color=blue]
                      > news:%23oVJWL9n EHA.3428@TK2MSF TNGP11.phx.gbl. ..[color=green]
                      > > Yes but this is a circle, what you refer to is a rectangle test. I think
                      > > the
                      > > OP wanted to only fire events or trigger action at least when the mouse
                      > > was
                      > > inside a defined pie chart or ( circle )
                      > >
                      > > --
                      > >
                      > > OHM ( Terry Burns )
                      > > . . . One-Handed-Man . . .
                      > > If U Need My Email ,Ask Me
                      > >
                      > > Time flies when you don't know what you're doing
                      > >
                      > > "Ken Tucker [MVP]" <vb2ae@bellsout h.net> wrote in message
                      > > news:euDzHg8nEH A.2840@TK2MSFTN GP10.phx.gbl...[color=darkred]
                      > >> Hi,
                      > >>
                      > >> Wouldnt region.isvisibl e be easier?
                      > >>
                      > >>[/color]
                      > >[/color][/color]
                      http://msdn.microsoft.com/library/de...sibletopic.asp[color=blue][color=green][color=darkred]
                      > >>
                      > >>
                      > >> Ken
                      > >> ---------------------
                      > >> "One Handed Man ( OHM - Terry Burns )" <news.microsoft .com> wrote in[/color]
                      > > message[color=darkred]
                      > >> news:uMRout7nEH A.3868@TK2MSFTN GP11.phx.gbl...
                      > >> No the answer is easier than that.
                      > >>
                      > >>
                      > >> You take the centre of the client area and compute.
                      > >>
                      > >> For example, if the radius is 10 your client area is 20,20. Then the
                      > >> centre point is 10,10. If x, or y is larger than the centre point +
                      > >> or -
                      > >> the mouse coordinates then this is out
                      > >>
                      > >> Alternatively calculate the hypotenuse for any given point
                      > >>
                      > >>
                      > >> H*H = A*A + O*O
                      > >>
                      > >> Once you calculate the H = SQRT( A*A + O*O) you can compare this[/color][/color][/color]
                      against[color=blue][color=green]
                      > > the[color=darkred]
                      > >> Radius. to determin if the point is in.
                      > >>
                      > >>
                      > >>
                      > >>
                      > >> --
                      > >>
                      > >> OHM ( Terry Burns )
                      > >> . . . One-Handed-Man . . .
                      > >> If U Need My Email ,Ask Me
                      > >>
                      > >> Time flies when you don't know what you're doing
                      > >>
                      > >> "Lars Netzel" <[stop_spam]@host.topdomain > wrote in message
                      > >> news:O%23z$aT7n EHA.2948@TK2MSF TNGP11.phx.gbl. ..
                      > >> > Yes, it helps a little to understand how to get the posistion of the[/color]
                      > > mouse[color=darkred]
                      > >> > Cursor and compare with that op_Inequality but I'm not sure how to[/color][/color][/color]
                      get[color=blue][color=green]
                      > > the[color=darkred]
                      > >> > position to compare with... I mean, if I have the mouseCursor.. Do I[/color]
                      > > need[color=darkred]
                      > >> to
                      > >> > loop thru all the points within the Round Area and run the
                      > >> > op_inequality
                      > >> > test then, and how to I get the points for that Area...?
                      > >> >
                      > >> > /Lars
                      > >> >
                      > >> >
                      > >> >
                      > >> >
                      > >> >
                      > >> >
                      > >> > "Cor Ligthert" <notfirstname@p lanet.nl> skrev i meddelandet
                      > >> > news:uQzUO%236n EHA.1296@TK2MSF TNGP09.phx.gbl. ..
                      > >> > > Lars,
                      > >> > >
                      > >> > > Did you ever see this nice sample I once have made in the past?
                      > >> > >
                      > >> > > It should have parts of your question.
                      > >> > > (it needs only a form and paste the code in)
                      > >> > >
                      > >> > > I hope you can use it?
                      > >> > >
                      > >> > > Cor
                      > >> > >
                      > >> > > \\\made by Cor Ligthert from ideas I got from Herfried. K. Wagner[/color][/color][/color]
                      and[color=blue][color=green][color=darkred]
                      > >> > Fergus
                      > >> > > Cooney
                      > >> > > Private WithEvents button1 As New Button
                      > >> > > Private mouseX, mouseY As Integer
                      > >> > > Private myMouseDown As Boolean
                      > >> > > Private Sub Form1_Load(ByVa l sender As System.Object, _
                      > >> > > ByVal e As System.EventArg s) Handles MyBase.Load
                      > >> > > Dim g As New System.Drawing. Drawing2D.Graph icsPath
                      > >> > > g.AddString("HT H" & vbCrLf & "Cor", _
                      > >> > > System.Drawing. FontFamily.Gene ricSansSerif, _
                      > >> > > System.Drawing. FontStyle.Bold, 200, _
                      > >> > > New Point(0, 0), _
                      > >> > > System.Drawing. StringFormat.Ge nericDefault)
                      > >> > > Me.BackColor = Color.Red
                      > >> > > Me.Region = New System.Drawing. Region(g)
                      > >> > > g.Dispose()
                      > >> > > Me.AutoScaleBas eSize = New System.Drawing. Size(0, 0)
                      > >> > > Me.ClientSize = New System.Drawing. Size(500, 450)
                      > >> > > button1.BackCol or =
                      > >> System.Drawing. SystemColors.Ac tiveCaptionText
                      > >> > > button1.ForeCol or = System.Drawing. Color.Black
                      > >> > > button1.Locatio n = New System.Drawing. Point(425, 18)
                      > >> > > button1.Size = New System.Drawing. Size(20, 20)
                      > >> > > Me.Controls.Add (button1)
                      > >> > > button1.Text = "X"
                      > >> > > Me.Location = New System.Drawing. Point(50, 50)
                      > >> > > End Sub
                      > >> > > Private Sub Button1_Click(B yVal sender As Object, _
                      > >> > > ByVal e As System.EventArg s) Handles button1.Click
                      > >> > > Me.Close()
                      > >> > > End Sub
                      > >> > > Private Sub Form1_MouseDown (ByVal sender As Object, ByVal _
                      > >> > > e As System.Windows. Forms.MouseEven tArgs) Handles
                      > >> > > MyBase.MouseDow n
                      > >> > > myMouseDown = True
                      > >> > > mouseX = Cursor.Position .X - Me.Location.X
                      > >> > > mouseY = Cursor.Position .Y - Me.Location.Y
                      > >> > > End Sub
                      > >> > > Private Sub Form1_MouseMove (ByVal sender As Object, ByVal e _
                      > >> > > As System.Windows. Forms.MouseEven tArgs) Handles[/color][/color][/color]
                      MyBase.MouseMov e[color=blue][color=green][color=darkred]
                      > >> > > Static LastCursor As Point
                      > >> > > Dim NowCursor As Point = New Point(Cursor.Po sition.X,
                      > >> > > Cursor.Position .Y)
                      > >> > > If Point.op_Inequa lity(NowCursor, LastCursor) Then
                      > >> > > If myMouseDown Then
                      > >> > > Me.Location = New[/color]
                      > > System.Drawing. Point(Cursor.Po sition.X[color=darkred]
                      > >> _
                      > >> > > - mouseX, Cursor.Position .Y - mouseY)
                      > >> > > End If
                      > >> > > LastCursor = Cursor.Position
                      > >> > > End If
                      > >> > > End Sub
                      > >> > > Private Sub Form1_MouseUp(B yVal sender As Object, ByVal e As _
                      > >> > > System.Windows. Forms.MouseEven tArgs) Handles MyBase.MouseUp
                      > >> > > myMouseDown = False
                      > >> > > End Sub
                      > >> > > ///
                      > >> > >
                      > >> > >
                      > >> > > "Lars Netzel" <[stop_spam]@host.topdomain >
                      > >> > > > Hi!
                      > >> > > >
                      > >> > > > I have a round area which I want to be able to move the mouse[/color][/color][/color]
                      over[color=blue][color=green]
                      > > and[color=darkred]
                      > >> > > fire
                      > >> > > > off events... how do I do that?
                      > >> > > >
                      > >> > > > I have drawn a FillPie Graphics and I feel that there has to be a[/color]
                      > > way[color=darkred]
                      > >> of
                      > >> > > > getting to know if the mouse is over that area since I have the
                      > >> > > coordinates
                      > >> > > > to paint the Pie but I don't know where to start or what to look
                      > >> > > > for
                      > >> > > really.
                      > >> > > >
                      > >> > > > Best Regard
                      > >> > > > /Lars
                      > >> > > >
                      > >> > > >
                      > >> > >
                      > >> > >
                      > >> >
                      > >> >
                      > >>
                      > >>
                      > >>[/color]
                      > >
                      > >[/color]
                      >
                      >[/color]


                      Comment

                      • One Handed Man \( OHM - Terry Burns \)

                        #12
                        Re: Mouse Hover over round Area?

                        My Mistake,

                        Ken you were right and I was wrong.

                        Thanks

                        --

                        OHM ( Terry Burns )
                        . . . One-Handed-Man . . .
                        If U Need My Email ,Ask Me

                        Time flies when you don't know what you're doing

                        "Ken Tucker [MVP]" <vb2ae@bellsout h.net> wrote in message
                        news:euDzHg8nEH A.2840@TK2MSFTN GP10.phx.gbl...[color=blue]
                        > Hi,
                        >
                        > Wouldnt region.isvisibl e be easier?
                        >
                        >[/color]
                        http://msdn.microsoft.com/library/de...sibletopic.asp[color=blue]
                        >
                        >
                        > Ken
                        > ---------------------
                        > "One Handed Man ( OHM - Terry Burns )" <news.microsoft .com> wrote in[/color]
                        message[color=blue]
                        > news:uMRout7nEH A.3868@TK2MSFTN GP11.phx.gbl...
                        > No the answer is easier than that.
                        >
                        >
                        > You take the centre of the client area and compute.
                        >
                        > For example, if the radius is 10 your client area is 20,20. Then the
                        > centre point is 10,10. If x, or y is larger than the centre point + or -
                        > the mouse coordinates then this is out
                        >
                        > Alternatively calculate the hypotenuse for any given point
                        >
                        >
                        > H*H = A*A + O*O
                        >
                        > Once you calculate the H = SQRT( A*A + O*O) you can compare this against[/color]
                        the[color=blue]
                        > Radius. to determin if the point is in.
                        >
                        >
                        >
                        >
                        > --
                        >
                        > OHM ( Terry Burns )
                        > . . . One-Handed-Man . . .
                        > If U Need My Email ,Ask Me
                        >
                        > Time flies when you don't know what you're doing
                        >
                        > "Lars Netzel" <[stop_spam]@host.topdomain > wrote in message
                        > news:O%23z$aT7n EHA.2948@TK2MSF TNGP11.phx.gbl. ..[color=green]
                        > > Yes, it helps a little to understand how to get the posistion of the[/color][/color]
                        mouse[color=blue][color=green]
                        > > Cursor and compare with that op_Inequality but I'm not sure how to get[/color][/color]
                        the[color=blue][color=green]
                        > > position to compare with... I mean, if I have the mouseCursor.. Do I[/color][/color]
                        need[color=blue]
                        > to[color=green]
                        > > loop thru all the points within the Round Area and run the op_inequality
                        > > test then, and how to I get the points for that Area...?
                        > >
                        > > /Lars
                        > >
                        > >
                        > >
                        > >
                        > >
                        > >
                        > > "Cor Ligthert" <notfirstname@p lanet.nl> skrev i meddelandet
                        > > news:uQzUO%236n EHA.1296@TK2MSF TNGP09.phx.gbl. ..[color=darkred]
                        > > > Lars,
                        > > >
                        > > > Did you ever see this nice sample I once have made in the past?
                        > > >
                        > > > It should have parts of your question.
                        > > > (it needs only a form and paste the code in)
                        > > >
                        > > > I hope you can use it?
                        > > >
                        > > > Cor
                        > > >
                        > > > \\\made by Cor Ligthert from ideas I got from Herfried. K. Wagner and[/color]
                        > > Fergus[color=darkred]
                        > > > Cooney
                        > > > Private WithEvents button1 As New Button
                        > > > Private mouseX, mouseY As Integer
                        > > > Private myMouseDown As Boolean
                        > > > Private Sub Form1_Load(ByVa l sender As System.Object, _
                        > > > ByVal e As System.EventArg s) Handles MyBase.Load
                        > > > Dim g As New System.Drawing. Drawing2D.Graph icsPath
                        > > > g.AddString("HT H" & vbCrLf & "Cor", _
                        > > > System.Drawing. FontFamily.Gene ricSansSerif, _
                        > > > System.Drawing. FontStyle.Bold, 200, _
                        > > > New Point(0, 0), _
                        > > > System.Drawing. StringFormat.Ge nericDefault)
                        > > > Me.BackColor = Color.Red
                        > > > Me.Region = New System.Drawing. Region(g)
                        > > > g.Dispose()
                        > > > Me.AutoScaleBas eSize = New System.Drawing. Size(0, 0)
                        > > > Me.ClientSize = New System.Drawing. Size(500, 450)
                        > > > button1.BackCol or =[/color][/color]
                        > System.Drawing. SystemColors.Ac tiveCaptionText[color=green][color=darkred]
                        > > > button1.ForeCol or = System.Drawing. Color.Black
                        > > > button1.Locatio n = New System.Drawing. Point(425, 18)
                        > > > button1.Size = New System.Drawing. Size(20, 20)
                        > > > Me.Controls.Add (button1)
                        > > > button1.Text = "X"
                        > > > Me.Location = New System.Drawing. Point(50, 50)
                        > > > End Sub
                        > > > Private Sub Button1_Click(B yVal sender As Object, _
                        > > > ByVal e As System.EventArg s) Handles button1.Click
                        > > > Me.Close()
                        > > > End Sub
                        > > > Private Sub Form1_MouseDown (ByVal sender As Object, ByVal _
                        > > > e As System.Windows. Forms.MouseEven tArgs) Handles MyBase.MouseDow n
                        > > > myMouseDown = True
                        > > > mouseX = Cursor.Position .X - Me.Location.X
                        > > > mouseY = Cursor.Position .Y - Me.Location.Y
                        > > > End Sub
                        > > > Private Sub Form1_MouseMove (ByVal sender As Object, ByVal e _
                        > > > As System.Windows. Forms.MouseEven tArgs) Handles MyBase.MouseMov e
                        > > > Static LastCursor As Point
                        > > > Dim NowCursor As Point = New Point(Cursor.Po sition.X,
                        > > > Cursor.Position .Y)
                        > > > If Point.op_Inequa lity(NowCursor, LastCursor) Then
                        > > > If myMouseDown Then
                        > > > Me.Location = New[/color][/color][/color]
                        System.Drawing. Point(Cursor.Po sition.X[color=blue]
                        > _[color=green][color=darkred]
                        > > > - mouseX, Cursor.Position .Y - mouseY)
                        > > > End If
                        > > > LastCursor = Cursor.Position
                        > > > End If
                        > > > End Sub
                        > > > Private Sub Form1_MouseUp(B yVal sender As Object, ByVal e As _
                        > > > System.Windows. Forms.MouseEven tArgs) Handles MyBase.MouseUp
                        > > > myMouseDown = False
                        > > > End Sub
                        > > > ///
                        > > >
                        > > >
                        > > > "Lars Netzel" <[stop_spam]@host.topdomain >
                        > > > > Hi!
                        > > > >
                        > > > > I have a round area which I want to be able to move the mouse over[/color][/color][/color]
                        and[color=blue][color=green][color=darkred]
                        > > > fire
                        > > > > off events... how do I do that?
                        > > > >
                        > > > > I have drawn a FillPie Graphics and I feel that there has to be a[/color][/color][/color]
                        way[color=blue]
                        > of[color=green][color=darkred]
                        > > > > getting to know if the mouse is over that area since I have the
                        > > > coordinates
                        > > > > to paint the Pie but I don't know where to start or what to look for
                        > > > really.
                        > > > >
                        > > > > Best Regard
                        > > > > /Lars
                        > > > >
                        > > > >
                        > > >
                        > > >[/color]
                        > >
                        > >[/color]
                        >
                        >
                        >[/color]


                        Comment

                        • Jay B. Harlow [MVP - Outlook]

                          #13
                          Re: Mouse Hover over round Area?

                          OHM,
                          I would not (did not) say your were wrong! :-)

                          IMHO there are at least 3 ways to do every thing.

                          You just had a different way of seeing the problem & solving it. I used
                          GraphicsPath, Ken suggested Region. I also suggested creating a circular
                          control. I'm sure there are others, at least variations of what we all
                          suggested.

                          In case you were wondering to get a circular Region you need to start with a
                          circular GraphicsPath, which you pass to the constructor of the Region.

                          Just a thought
                          Jay

                          "One Handed Man ( OHM - Terry Burns )" <news.microsoft .com> wrote in message
                          news:eewi8Z%23n EHA.3520@TK2MSF TNGP11.phx.gbl. ..[color=blue]
                          > My Mistake,
                          >
                          > Ken you were right and I was wrong.
                          >
                          > Thanks
                          >
                          > --
                          >
                          > OHM ( Terry Burns )
                          > . . . One-Handed-Man . . .
                          > If U Need My Email ,Ask Me
                          >
                          > Time flies when you don't know what you're doing
                          >
                          > "Ken Tucker [MVP]" <vb2ae@bellsout h.net> wrote in message
                          > news:euDzHg8nEH A.2840@TK2MSFTN GP10.phx.gbl...[color=green]
                          >> Hi,
                          >>
                          >> Wouldnt region.isvisibl e be easier?
                          >>
                          >>[/color]
                          > http://msdn.microsoft.com/library/de...sibletopic.asp[color=green]
                          >>
                          >>
                          >> Ken
                          >> ---------------------
                          >> "One Handed Man ( OHM - Terry Burns )" <news.microsoft .com> wrote in[/color]
                          > message[color=green]
                          >> news:uMRout7nEH A.3868@TK2MSFTN GP11.phx.gbl...
                          >> No the answer is easier than that.
                          >>
                          >>
                          >> You take the centre of the client area and compute.
                          >>
                          >> For example, if the radius is 10 your client area is 20,20. Then the
                          >> centre point is 10,10. If x, or y is larger than the centre point +
                          >> or -
                          >> the mouse coordinates then this is out
                          >>
                          >> Alternatively calculate the hypotenuse for any given point
                          >>
                          >>
                          >> H*H = A*A + O*O
                          >>
                          >> Once you calculate the H = SQRT( A*A + O*O) you can compare this against[/color]
                          > the[color=green]
                          >> Radius. to determin if the point is in.
                          >>
                          >>
                          >>
                          >>
                          >> --
                          >>
                          >> OHM ( Terry Burns )
                          >> . . . One-Handed-Man . . .
                          >> If U Need My Email ,Ask Me
                          >>
                          >> Time flies when you don't know what you're doing
                          >>
                          >> "Lars Netzel" <[stop_spam]@host.topdomain > wrote in message
                          >> news:O%23z$aT7n EHA.2948@TK2MSF TNGP11.phx.gbl. ..[color=darkred]
                          >> > Yes, it helps a little to understand how to get the posistion of the[/color][/color]
                          > mouse[color=green][color=darkred]
                          >> > Cursor and compare with that op_Inequality but I'm not sure how to get[/color][/color]
                          > the[color=green][color=darkred]
                          >> > position to compare with... I mean, if I have the mouseCursor.. Do I[/color][/color]
                          > need[color=green]
                          >> to[color=darkred]
                          >> > loop thru all the points within the Round Area and run the
                          >> > op_inequality
                          >> > test then, and how to I get the points for that Area...?
                          >> >
                          >> > /Lars
                          >> >
                          >> >
                          >> >
                          >> >
                          >> >
                          >> >
                          >> > "Cor Ligthert" <notfirstname@p lanet.nl> skrev i meddelandet
                          >> > news:uQzUO%236n EHA.1296@TK2MSF TNGP09.phx.gbl. ..
                          >> > > Lars,
                          >> > >
                          >> > > Did you ever see this nice sample I once have made in the past?
                          >> > >
                          >> > > It should have parts of your question.
                          >> > > (it needs only a form and paste the code in)
                          >> > >
                          >> > > I hope you can use it?
                          >> > >
                          >> > > Cor
                          >> > >
                          >> > > \\\made by Cor Ligthert from ideas I got from Herfried. K. Wagner and
                          >> > Fergus
                          >> > > Cooney
                          >> > > Private WithEvents button1 As New Button
                          >> > > Private mouseX, mouseY As Integer
                          >> > > Private myMouseDown As Boolean
                          >> > > Private Sub Form1_Load(ByVa l sender As System.Object, _
                          >> > > ByVal e As System.EventArg s) Handles MyBase.Load
                          >> > > Dim g As New System.Drawing. Drawing2D.Graph icsPath
                          >> > > g.AddString("HT H" & vbCrLf & "Cor", _
                          >> > > System.Drawing. FontFamily.Gene ricSansSerif, _
                          >> > > System.Drawing. FontStyle.Bold, 200, _
                          >> > > New Point(0, 0), _
                          >> > > System.Drawing. StringFormat.Ge nericDefault)
                          >> > > Me.BackColor = Color.Red
                          >> > > Me.Region = New System.Drawing. Region(g)
                          >> > > g.Dispose()
                          >> > > Me.AutoScaleBas eSize = New System.Drawing. Size(0, 0)
                          >> > > Me.ClientSize = New System.Drawing. Size(500, 450)
                          >> > > button1.BackCol or =[/color]
                          >> System.Drawing. SystemColors.Ac tiveCaptionText[color=darkred]
                          >> > > button1.ForeCol or = System.Drawing. Color.Black
                          >> > > button1.Locatio n = New System.Drawing. Point(425, 18)
                          >> > > button1.Size = New System.Drawing. Size(20, 20)
                          >> > > Me.Controls.Add (button1)
                          >> > > button1.Text = "X"
                          >> > > Me.Location = New System.Drawing. Point(50, 50)
                          >> > > End Sub
                          >> > > Private Sub Button1_Click(B yVal sender As Object, _
                          >> > > ByVal e As System.EventArg s) Handles button1.Click
                          >> > > Me.Close()
                          >> > > End Sub
                          >> > > Private Sub Form1_MouseDown (ByVal sender As Object, ByVal _
                          >> > > e As System.Windows. Forms.MouseEven tArgs) Handles
                          >> > > MyBase.MouseDow n
                          >> > > myMouseDown = True
                          >> > > mouseX = Cursor.Position .X - Me.Location.X
                          >> > > mouseY = Cursor.Position .Y - Me.Location.Y
                          >> > > End Sub
                          >> > > Private Sub Form1_MouseMove (ByVal sender As Object, ByVal e _
                          >> > > As System.Windows. Forms.MouseEven tArgs) Handles MyBase.MouseMov e
                          >> > > Static LastCursor As Point
                          >> > > Dim NowCursor As Point = New Point(Cursor.Po sition.X,
                          >> > > Cursor.Position .Y)
                          >> > > If Point.op_Inequa lity(NowCursor, LastCursor) Then
                          >> > > If myMouseDown Then
                          >> > > Me.Location = New[/color][/color]
                          > System.Drawing. Point(Cursor.Po sition.X[color=green]
                          >> _[color=darkred]
                          >> > > - mouseX, Cursor.Position .Y - mouseY)
                          >> > > End If
                          >> > > LastCursor = Cursor.Position
                          >> > > End If
                          >> > > End Sub
                          >> > > Private Sub Form1_MouseUp(B yVal sender As Object, ByVal e As _
                          >> > > System.Windows. Forms.MouseEven tArgs) Handles MyBase.MouseUp
                          >> > > myMouseDown = False
                          >> > > End Sub
                          >> > > ///
                          >> > >
                          >> > >
                          >> > > "Lars Netzel" <[stop_spam]@host.topdomain >
                          >> > > > Hi!
                          >> > > >
                          >> > > > I have a round area which I want to be able to move the mouse over[/color][/color]
                          > and[color=green][color=darkred]
                          >> > > fire
                          >> > > > off events... how do I do that?
                          >> > > >
                          >> > > > I have drawn a FillPie Graphics and I feel that there has to be a[/color][/color]
                          > way[color=green]
                          >> of[color=darkred]
                          >> > > > getting to know if the mouse is over that area since I have the
                          >> > > coordinates
                          >> > > > to paint the Pie but I don't know where to start or what to look
                          >> > > > for
                          >> > > really.
                          >> > > >
                          >> > > > Best Regard
                          >> > > > /Lars
                          >> > > >
                          >> > > >
                          >> > >
                          >> > >
                          >> >
                          >> >[/color]
                          >>
                          >>
                          >>[/color]
                          >
                          >[/color]


                          Comment

                          • One Handed Man \( OHM - Terry Burns \)

                            #14
                            Re: Mouse Hover over round Area?

                            No worries, thanks Jay.

                            --

                            OHM ( Terry Burns )
                            . . . One-Handed-Man . . .
                            If U Need My Email ,Ask Me

                            Time flies when you don't know what you're doing

                            "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP @msn.com> wrote in message
                            news:OL2TDv%23n EHA.3392@TK2MSF TNGP15.phx.gbl. ..[color=blue]
                            > OHM,
                            > I would not (did not) say your were wrong! :-)
                            >
                            > IMHO there are at least 3 ways to do every thing.
                            >
                            > You just had a different way of seeing the problem & solving it. I used
                            > GraphicsPath, Ken suggested Region. I also suggested creating a circular
                            > control. I'm sure there are others, at least variations of what we all
                            > suggested.
                            >
                            > In case you were wondering to get a circular Region you need to start with[/color]
                            a[color=blue]
                            > circular GraphicsPath, which you pass to the constructor of the Region.
                            >
                            > Just a thought
                            > Jay
                            >
                            > "One Handed Man ( OHM - Terry Burns )" <news.microsoft .com> wrote in[/color]
                            message[color=blue]
                            > news:eewi8Z%23n EHA.3520@TK2MSF TNGP11.phx.gbl. ..[color=green]
                            > > My Mistake,
                            > >
                            > > Ken you were right and I was wrong.
                            > >
                            > > Thanks
                            > >
                            > > --
                            > >
                            > > OHM ( Terry Burns )
                            > > . . . One-Handed-Man . . .
                            > > If U Need My Email ,Ask Me
                            > >
                            > > Time flies when you don't know what you're doing
                            > >
                            > > "Ken Tucker [MVP]" <vb2ae@bellsout h.net> wrote in message
                            > > news:euDzHg8nEH A.2840@TK2MSFTN GP10.phx.gbl...[color=darkred]
                            > >> Hi,
                            > >>
                            > >> Wouldnt region.isvisibl e be easier?
                            > >>
                            > >>[/color]
                            > >[/color][/color]
                            http://msdn.microsoft.com/library/de...sibletopic.asp[color=blue][color=green][color=darkred]
                            > >>
                            > >>
                            > >> Ken
                            > >> ---------------------
                            > >> "One Handed Man ( OHM - Terry Burns )" <news.microsoft .com> wrote in[/color]
                            > > message[color=darkred]
                            > >> news:uMRout7nEH A.3868@TK2MSFTN GP11.phx.gbl...
                            > >> No the answer is easier than that.
                            > >>
                            > >>
                            > >> You take the centre of the client area and compute.
                            > >>
                            > >> For example, if the radius is 10 your client area is 20,20. Then the
                            > >> centre point is 10,10. If x, or y is larger than the centre point +
                            > >> or -
                            > >> the mouse coordinates then this is out
                            > >>
                            > >> Alternatively calculate the hypotenuse for any given point
                            > >>
                            > >>
                            > >> H*H = A*A + O*O
                            > >>
                            > >> Once you calculate the H = SQRT( A*A + O*O) you can compare this[/color][/color][/color]
                            against[color=blue][color=green]
                            > > the[color=darkred]
                            > >> Radius. to determin if the point is in.
                            > >>
                            > >>
                            > >>
                            > >>
                            > >> --
                            > >>
                            > >> OHM ( Terry Burns )
                            > >> . . . One-Handed-Man . . .
                            > >> If U Need My Email ,Ask Me
                            > >>
                            > >> Time flies when you don't know what you're doing
                            > >>
                            > >> "Lars Netzel" <[stop_spam]@host.topdomain > wrote in message
                            > >> news:O%23z$aT7n EHA.2948@TK2MSF TNGP11.phx.gbl. ..
                            > >> > Yes, it helps a little to understand how to get the posistion of the[/color]
                            > > mouse[color=darkred]
                            > >> > Cursor and compare with that op_Inequality but I'm not sure how to[/color][/color][/color]
                            get[color=blue][color=green]
                            > > the[color=darkred]
                            > >> > position to compare with... I mean, if I have the mouseCursor.. Do I[/color]
                            > > need[color=darkred]
                            > >> to
                            > >> > loop thru all the points within the Round Area and run the
                            > >> > op_inequality
                            > >> > test then, and how to I get the points for that Area...?
                            > >> >
                            > >> > /Lars
                            > >> >
                            > >> >
                            > >> >
                            > >> >
                            > >> >
                            > >> >
                            > >> > "Cor Ligthert" <notfirstname@p lanet.nl> skrev i meddelandet
                            > >> > news:uQzUO%236n EHA.1296@TK2MSF TNGP09.phx.gbl. ..
                            > >> > > Lars,
                            > >> > >
                            > >> > > Did you ever see this nice sample I once have made in the past?
                            > >> > >
                            > >> > > It should have parts of your question.
                            > >> > > (it needs only a form and paste the code in)
                            > >> > >
                            > >> > > I hope you can use it?
                            > >> > >
                            > >> > > Cor
                            > >> > >
                            > >> > > \\\made by Cor Ligthert from ideas I got from Herfried. K. Wagner[/color][/color][/color]
                            and[color=blue][color=green][color=darkred]
                            > >> > Fergus
                            > >> > > Cooney
                            > >> > > Private WithEvents button1 As New Button
                            > >> > > Private mouseX, mouseY As Integer
                            > >> > > Private myMouseDown As Boolean
                            > >> > > Private Sub Form1_Load(ByVa l sender As System.Object, _
                            > >> > > ByVal e As System.EventArg s) Handles MyBase.Load
                            > >> > > Dim g As New System.Drawing. Drawing2D.Graph icsPath
                            > >> > > g.AddString("HT H" & vbCrLf & "Cor", _
                            > >> > > System.Drawing. FontFamily.Gene ricSansSerif, _
                            > >> > > System.Drawing. FontStyle.Bold, 200, _
                            > >> > > New Point(0, 0), _
                            > >> > > System.Drawing. StringFormat.Ge nericDefault)
                            > >> > > Me.BackColor = Color.Red
                            > >> > > Me.Region = New System.Drawing. Region(g)
                            > >> > > g.Dispose()
                            > >> > > Me.AutoScaleBas eSize = New System.Drawing. Size(0, 0)
                            > >> > > Me.ClientSize = New System.Drawing. Size(500, 450)
                            > >> > > button1.BackCol or =
                            > >> System.Drawing. SystemColors.Ac tiveCaptionText
                            > >> > > button1.ForeCol or = System.Drawing. Color.Black
                            > >> > > button1.Locatio n = New System.Drawing. Point(425, 18)
                            > >> > > button1.Size = New System.Drawing. Size(20, 20)
                            > >> > > Me.Controls.Add (button1)
                            > >> > > button1.Text = "X"
                            > >> > > Me.Location = New System.Drawing. Point(50, 50)
                            > >> > > End Sub
                            > >> > > Private Sub Button1_Click(B yVal sender As Object, _
                            > >> > > ByVal e As System.EventArg s) Handles button1.Click
                            > >> > > Me.Close()
                            > >> > > End Sub
                            > >> > > Private Sub Form1_MouseDown (ByVal sender As Object, ByVal _
                            > >> > > e As System.Windows. Forms.MouseEven tArgs) Handles
                            > >> > > MyBase.MouseDow n
                            > >> > > myMouseDown = True
                            > >> > > mouseX = Cursor.Position .X - Me.Location.X
                            > >> > > mouseY = Cursor.Position .Y - Me.Location.Y
                            > >> > > End Sub
                            > >> > > Private Sub Form1_MouseMove (ByVal sender As Object, ByVal e _
                            > >> > > As System.Windows. Forms.MouseEven tArgs) Handles[/color][/color][/color]
                            MyBase.MouseMov e[color=blue][color=green][color=darkred]
                            > >> > > Static LastCursor As Point
                            > >> > > Dim NowCursor As Point = New Point(Cursor.Po sition.X,
                            > >> > > Cursor.Position .Y)
                            > >> > > If Point.op_Inequa lity(NowCursor, LastCursor) Then
                            > >> > > If myMouseDown Then
                            > >> > > Me.Location = New[/color]
                            > > System.Drawing. Point(Cursor.Po sition.X[color=darkred]
                            > >> _
                            > >> > > - mouseX, Cursor.Position .Y - mouseY)
                            > >> > > End If
                            > >> > > LastCursor = Cursor.Position
                            > >> > > End If
                            > >> > > End Sub
                            > >> > > Private Sub Form1_MouseUp(B yVal sender As Object, ByVal e As _
                            > >> > > System.Windows. Forms.MouseEven tArgs) Handles MyBase.MouseUp
                            > >> > > myMouseDown = False
                            > >> > > End Sub
                            > >> > > ///
                            > >> > >
                            > >> > >
                            > >> > > "Lars Netzel" <[stop_spam]@host.topdomain >
                            > >> > > > Hi!
                            > >> > > >
                            > >> > > > I have a round area which I want to be able to move the mouse[/color][/color][/color]
                            over[color=blue][color=green]
                            > > and[color=darkred]
                            > >> > > fire
                            > >> > > > off events... how do I do that?
                            > >> > > >
                            > >> > > > I have drawn a FillPie Graphics and I feel that there has to be a[/color]
                            > > way[color=darkred]
                            > >> of
                            > >> > > > getting to know if the mouse is over that area since I have the
                            > >> > > coordinates
                            > >> > > > to paint the Pie but I don't know where to start or what to look
                            > >> > > > for
                            > >> > > really.
                            > >> > > >
                            > >> > > > Best Regard
                            > >> > > > /Lars
                            > >> > > >
                            > >> > > >
                            > >> > >
                            > >> > >
                            > >> >
                            > >> >
                            > >>
                            > >>
                            > >>[/color]
                            > >
                            > >[/color]
                            >
                            >[/color]


                            Comment

                            Working...