Mouse Hover over round Area?

  • Thread starter Thread starter Lars Netzel
  • Start date Start date
L

Lars Netzel

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
 
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(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim g As New System.Drawing.Drawing2D.GraphicsPath
g.AddString("HTH" & vbCrLf & "Cor", _
System.Drawing.FontFamily.GenericSansSerif, _
System.Drawing.FontStyle.Bold, 200, _
New Point(0, 0), _
System.Drawing.StringFormat.GenericDefault)
Me.BackColor = Color.Red
Me.Region = New System.Drawing.Region(g)
g.Dispose()
Me.AutoScaleBaseSize = New System.Drawing.Size(0, 0)
Me.ClientSize = New System.Drawing.Size(500, 450)
button1.BackColor = System.Drawing.SystemColors.ActiveCaptionText
button1.ForeColor = System.Drawing.Color.Black
button1.Location = 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(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles button1.Click
Me.Close()
End Sub
Private Sub Form1_MouseDown(ByVal sender As Object, ByVal _
e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
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.MouseEventArgs) Handles MyBase.MouseMove
Static LastCursor As Point
Dim NowCursor As Point = New Point(Cursor.Position.X,
Cursor.Position.Y)
If Point.op_Inequality(NowCursor, LastCursor) Then
If myMouseDown Then
Me.Location = New System.Drawing.Point(Cursor.Position.X _
- mouseX, Cursor.Position.Y - mouseY)
End If
LastCursor = Cursor.Position
End If
End Sub
Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As _
System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseUp
myMouseDown = False
End Sub
///
 
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
 
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
 
Hi,

Dim rgnCircle As Region

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim pth As New System.Drawing.Drawing2D.GraphicsPath

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

rgnCircle = New Region(pth)

End Sub

Private Sub Form1_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint

e.Graphics.FillRegion(Brushes.Blue, rgnCircle)

End Sub

Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove

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

End Sub



Ken

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

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
 
Hi,

Wouldnt region.isvisible be easier?

http://msdn.microsoft.com/library/d...lrfsystemdrawingregionclassisvisibletopic.asp


Ken
---------------------
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
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
 
I tested this , it may not be the most efficient, but it works

Private cp As Point

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim g As Graphics

g = pBox.CreateGraphics

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

g.DrawEllipse(New 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.MouseEventArgs) 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.WriteLine("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
 
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 said:
Hi,

Wouldnt region.isvisible be easier?

http://msdn.microsoft.com/library/d...lrfsystemdrawingregionclassisvisibletopic.asp


Ken
---------------------
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
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 said:
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
System.Drawing.Point(Cursor.Position.X
_
- mouseX, Cursor.Position.Y - mouseY)
End If
LastCursor = Cursor.Position
End If
End Sub
Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As _
System.Windows.Forms.MouseEventArgs) 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 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
 
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 ) said:
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 said:
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
System.Drawing.Point(Cursor.Position.X
_
- mouseX, Cursor.Position.Y - mouseY)
End If
LastCursor = Cursor.Position
End If
End Sub
Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As _
System.Windows.Forms.MouseEventArgs) 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 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
 
OHM,
But a Region (GraphicsPath really) can be circular!

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


So you could use either Region.IsVisible or GraphicsPath.IsVisible.

Borrowing your earlier code (untested):
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim g As Graphics

g = pBox.CreateGraphics

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

g.DrawEllipse(New 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.MouseEventArgs) Handles pBox.MouseMove
Dim path As New System.Drawing.Drawing2D.GraphicsPath
Dim cp As New Point(pBox.Size.Width / 2, pBox.Size.Height / 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


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 ) said:
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 said:
Hi,

Wouldnt region.isvisible be easier?

http://msdn.microsoft.com/library/d...lrfsystemdrawingregionclassisvisibletopic.asp


Ken
---------------------
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
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 said:
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" <[email protected]> skrev i meddelandet
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(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim g As New System.Drawing.Drawing2D.GraphicsPath
g.AddString("HTH" & vbCrLf & "Cor", _
System.Drawing.FontFamily.GenericSansSerif, _
System.Drawing.FontStyle.Bold, 200, _
New Point(0, 0), _
System.Drawing.StringFormat.GenericDefault)
Me.BackColor = Color.Red
Me.Region = New System.Drawing.Region(g)
g.Dispose()
Me.AutoScaleBaseSize = New System.Drawing.Size(0, 0)
Me.ClientSize = New System.Drawing.Size(500, 450)
button1.BackColor = System.Drawing.SystemColors.ActiveCaptionText
button1.ForeColor = System.Drawing.Color.Black
button1.Location = 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(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles button1.Click
Me.Close()
End Sub
Private Sub Form1_MouseDown(ByVal sender As Object, ByVal _
e As System.Windows.Forms.MouseEventArgs) Handles
MyBase.MouseDown
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.MouseEventArgs) Handles MyBase.MouseMove
Static LastCursor As Point
Dim NowCursor As Point = New Point(Cursor.Position.X,
Cursor.Position.Y)
If Point.op_Inequality(NowCursor, LastCursor) Then
If myMouseDown Then
Me.Location = New
System.Drawing.Point(Cursor.Position.X
_
- mouseX, Cursor.Position.Y - mouseY)
End If
LastCursor = Cursor.Position
End If
End Sub
Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As _
System.Windows.Forms.MouseEventArgs) 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 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
 
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 said:
OHM,
But a Region (GraphicsPath really) can be circular!

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


So you could use either Region.IsVisible or GraphicsPath.IsVisible.

Borrowing your earlier code (untested):
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim g As Graphics

g = pBox.CreateGraphics

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

g.DrawEllipse(New 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.MouseEventArgs) Handles pBox.MouseMove
Dim path As New System.Drawing.Drawing2D.GraphicsPath
Dim cp As New Point(pBox.Size.Width / 2, pBox.Size.Height / 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


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
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 said:
Hi,

Wouldnt region.isvisible be easier?
http://msdn.microsoft.com/library/d...lrfsystemdrawingregionclassisvisibletopic.asp
Ken
---------------------
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
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

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" <[email protected]> skrev i meddelandet
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(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim g As New System.Drawing.Drawing2D.GraphicsPath
g.AddString("HTH" & vbCrLf & "Cor", _
System.Drawing.FontFamily.GenericSansSerif, _
System.Drawing.FontStyle.Bold, 200, _
New Point(0, 0), _
System.Drawing.StringFormat.GenericDefault)
Me.BackColor = Color.Red
Me.Region = New System.Drawing.Region(g)
g.Dispose()
Me.AutoScaleBaseSize = New System.Drawing.Size(0, 0)
Me.ClientSize = New System.Drawing.Size(500, 450)
button1.BackColor =
System.Drawing.SystemColors.ActiveCaptionText
button1.ForeColor = System.Drawing.Color.Black
button1.Location = 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(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles button1.Click
Me.Close()
End Sub
Private Sub Form1_MouseDown(ByVal sender As Object, ByVal _
e As System.Windows.Forms.MouseEventArgs) Handles
MyBase.MouseDown
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.MouseEventArgs) Handles MyBase.MouseMove
Static LastCursor As Point
Dim NowCursor As Point = New Point(Cursor.Position.X,
Cursor.Position.Y)
If Point.op_Inequality(NowCursor, LastCursor) Then
If myMouseDown Then
Me.Location = New System.Drawing.Point(Cursor.Position.X
_
- mouseX, Cursor.Position.Y - mouseY)
End If
LastCursor = Cursor.Position
End If
End Sub
Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As _
System.Windows.Forms.MouseEventArgs) 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
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
 
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 said:
Hi,

Wouldnt region.isvisible be easier?

http://msdn.microsoft.com/library/d...lrfsystemdrawingregionclassisvisibletopic.asp


Ken
---------------------
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
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 said:
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
System.Drawing.Point(Cursor.Position.X
_
- mouseX, Cursor.Position.Y - mouseY)
End If
LastCursor = Cursor.Position
End If
End Sub
Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As _
System.Windows.Forms.MouseEventArgs) 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 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
 
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 ) said:
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 said:
Hi,

Wouldnt region.isvisible be easier?

http://msdn.microsoft.com/library/d...lrfsystemdrawingregionclassisvisibletopic.asp


Ken
---------------------
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
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 said:
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" <[email protected]> skrev i meddelandet
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(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim g As New System.Drawing.Drawing2D.GraphicsPath
g.AddString("HTH" & vbCrLf & "Cor", _
System.Drawing.FontFamily.GenericSansSerif, _
System.Drawing.FontStyle.Bold, 200, _
New Point(0, 0), _
System.Drawing.StringFormat.GenericDefault)
Me.BackColor = Color.Red
Me.Region = New System.Drawing.Region(g)
g.Dispose()
Me.AutoScaleBaseSize = New System.Drawing.Size(0, 0)
Me.ClientSize = New System.Drawing.Size(500, 450)
button1.BackColor = System.Drawing.SystemColors.ActiveCaptionText
button1.ForeColor = System.Drawing.Color.Black
button1.Location = 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(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles button1.Click
Me.Close()
End Sub
Private Sub Form1_MouseDown(ByVal sender As Object, ByVal _
e As System.Windows.Forms.MouseEventArgs) Handles
MyBase.MouseDown
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.MouseEventArgs) Handles MyBase.MouseMove
Static LastCursor As Point
Dim NowCursor As Point = New Point(Cursor.Position.X,
Cursor.Position.Y)
If Point.op_Inequality(NowCursor, LastCursor) Then
If myMouseDown Then
Me.Location = New
System.Drawing.Point(Cursor.Position.X
_
- mouseX, Cursor.Position.Y - mouseY)
End If
LastCursor = Cursor.Position
End If
End Sub
Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As _
System.Windows.Forms.MouseEventArgs) 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 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
 
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 said:
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
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 said:
Hi,

Wouldnt region.isvisible be easier?
http://msdn.microsoft.com/library/d...lrfsystemdrawingregionclassisvisibletopic.asp
Ken
---------------------
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
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

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" <[email protected]> skrev i meddelandet
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(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim g As New System.Drawing.Drawing2D.GraphicsPath
g.AddString("HTH" & vbCrLf & "Cor", _
System.Drawing.FontFamily.GenericSansSerif, _
System.Drawing.FontStyle.Bold, 200, _
New Point(0, 0), _
System.Drawing.StringFormat.GenericDefault)
Me.BackColor = Color.Red
Me.Region = New System.Drawing.Region(g)
g.Dispose()
Me.AutoScaleBaseSize = New System.Drawing.Size(0, 0)
Me.ClientSize = New System.Drawing.Size(500, 450)
button1.BackColor =
System.Drawing.SystemColors.ActiveCaptionText
button1.ForeColor = System.Drawing.Color.Black
button1.Location = 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(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles button1.Click
Me.Close()
End Sub
Private Sub Form1_MouseDown(ByVal sender As Object, ByVal _
e As System.Windows.Forms.MouseEventArgs) Handles
MyBase.MouseDown
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.MouseEventArgs) Handles MyBase.MouseMove
Static LastCursor As Point
Dim NowCursor As Point = New Point(Cursor.Position.X,
Cursor.Position.Y)
If Point.op_Inequality(NowCursor, LastCursor) Then
If myMouseDown Then
Me.Location = New System.Drawing.Point(Cursor.Position.X
_
- mouseX, Cursor.Position.Y - mouseY)
End If
LastCursor = Cursor.Position
End If
End Sub
Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As _
System.Windows.Forms.MouseEventArgs) 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
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top