473,765 Members | 2,134 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
Nov 21 '05 #1
13 3154
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 >
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

Nov 21 '05 #2
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" <no**********@p lanet.nl> skrev i meddelandet
news:uQ******** ********@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 = 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 >
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


Nov 21 '05 #3
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%******** ********@TK2MSF TNGP11.phx.gbl. ..
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" <no**********@p lanet.nl> skrev i meddelandet
news:uQ******** ********@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 = 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 >
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



Nov 21 '05 #4
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:eF******** ******@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

Nov 21 '05 #5
Hi,

Wouldnt region.isvisibl e be easier?

http://msdn.microsoft.com/library/de...sibletopic.asp
Ken
---------------------
"One Handed Man ( OHM - Terry Burns )" <news.microsoft .com> wrote in message
news:uM******** ******@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%******** ********@TK2MSF TNGP11.phx.gbl. ..
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" <no**********@p lanet.nl> skrev i meddelandet
news:uQ******** ********@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 = 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 >
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




Nov 21 '05 #6
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%******** ********@TK2MSF TNGP11.phx.gbl. ..
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" <no**********@p lanet.nl> skrev i meddelandet
news:uQ******** ********@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 = 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 >
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



Nov 21 '05 #7
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]" <vb***@bellsout h.net> wrote in message
news:eu******** ******@TK2MSFTN GP10.phx.gbl...
Hi,

Wouldnt region.isvisibl e be easier?

http://msdn.microsoft.com/library/de...sibletopic.asp

Ken
---------------------
"One Handed Man ( OHM - Terry Burns )" <news.microsoft .com> wrote in message news:uM******** ******@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%******** ********@TK2MSF TNGP11.phx.gbl. ..
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" <no**********@p lanet.nl> skrev i meddelandet
news:uQ******** ********@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 =

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



Nov 21 '05 #8
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:uM******** ******@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%******** ********@TK2MSF TNGP11.phx.gbl. ..
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" <no**********@p lanet.nl> skrev i meddelandet
news:uQ******** ********@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 =

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



Nov 21 '05 #9
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):
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 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

End Sub

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:%2******** ********@TK2MSF TNGP11.phx.gbl. .. 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]" <vb***@bellsout h.net> wrote in message
news:eu******** ******@TK2MSFTN GP10.phx.gbl...
Hi,

Wouldnt region.isvisibl e be easier?

http://msdn.microsoft.com/library/de...sibletopic.asp


Ken
---------------------
"One Handed Man ( OHM - Terry Burns )" <news.microsoft .com> wrote in

message
news:uM******** ******@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%******** ********@TK2MSF TNGP11.phx.gbl. ..
> 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" <no**********@p lanet.nl> skrev i meddelandet
> news:uQ******** ********@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 =

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



Nov 21 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
9481
by: Paul Kaufman | last post by:
What do I add to the style sheet to do this? Thanks. -Paul, the CSS Newbie
4
2254
by: Raj Chudasama | last post by:
I have a controls similiar to the windows calculator. (Please press some buttons on your calculator to see what i am talking about) So when u hover over a button it will change the state (it changes to different image) if u click it will show pressed image etc now the problem: the calculator does the following
0
1460
by: StriderBob | last post by:
In a simple two form project, use a button on each form to Show() the other form and Hide() the current form. Add MouseEnter and MouseLeave events to both buttons so they change the image on each button when they are NOT Clicked but the cursor enters their boundary. This setup works fine. If the mouse cursor enters the button on the first form the image changes and if the button is clicked the first form disappears and the other form...
4
8155
by: Fokke Nauta | last post by:
Hi all, I am searching for a script which does the following: I have a frameset with two pages: left and right. On the left page there is an image map. When I hover the mouse over a certain area of the image map, I want to appear an image in the right page. There are more area's on the image map. I want a specific picture to appear, each one correlated to a specific area. Is there any scrip which can do this?
4
19560
by: Amy | last post by:
I need some help. I have this table with alternate row colors. Class gray and class white. I have javascript that do highlight when mouseover row ... and onclick to select row and highlight it with another color. Also created a class called "Selected". You can only select a row at a time. My problem is, if a row is preselected, when mouseover the selected row, the selected color is screwed. Until you click on the selected row once, the...
1
4600
by: Andy Baxter | last post by:
hello, I'm writing a panoramic image viewer in javascript. When the mouse is over the image, I want it to be a crosshair (over most of the image), or a hand/pointer (when it's over an image map region). The image map is created in javascript, but doesn't set any 'cursor' style rules. The problem I'm having is I have two images embedded inside two divs. The outer div has style='... cursor:crosshair', but when I move over the image...
3
4337
by: Spam Catcher | last post by:
Hi all, I'm having some trouble with the Mouse Hover/Leave events on a user control. Say I have a user control with a panel covering the whole control. In turn, a label + picture box cover the panel. If the mouse is anywhere over the user control, I want the background colour to change.
5
8078
by: kimiraikkonen | last post by:
Hi, I couldn't find a necessary class which shows when mouse hovers on a link in Webbrowser control. Think of there's a status bar(text), when mouse comes on a link, the URL must be shown in this status bar. How can i do this? Thanks.
5
3397
by: vidishasharma | last post by:
Hi, I have a windows from with few controls over it. Now I have to see if the cursor goes outside the bounds of the windows form then I have to close the form. I added mouse leave for the form however as soon as the cursor goes on any control over the form form_ MouseLeave is fired. I want to this to be fired only if it goes outside the bounds of the
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9398
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10007
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9951
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9832
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8831
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5419
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3531
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2805
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.