473,382 Members | 1,717 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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

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**********@planet.nl> skrev i meddelandet
news:uQ****************@TK2MSFTNGP09.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(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


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%****************@TK2MSFTNGP11.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**********@planet.nl> skrev i meddelandet
news:uQ****************@TK2MSFTNGP09.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(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



Nov 21 '05 #4
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

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

"Lars Netzel" <[stop_spam]@host.topdomain> wrote in message
news:eF**************@tk2msftngp13.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.isvisible 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**************@TK2MSFTNGP11.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%****************@TK2MSFTNGP11.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**********@planet.nl> skrev i meddelandet
news:uQ****************@TK2MSFTNGP09.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(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




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

"Lars Netzel" <[stop_spam]@host.topdomain> wrote in message
news:O%****************@TK2MSFTNGP11.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**********@planet.nl> skrev i meddelandet
news:uQ****************@TK2MSFTNGP09.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(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



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***@bellsouth.net> wrote in message
news:eu**************@TK2MSFTNGP10.phx.gbl...
Hi,

Wouldnt region.isvisible 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**************@TK2MSFTNGP11.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%****************@TK2MSFTNGP11.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**********@planet.nl> skrev i meddelandet
news:uQ****************@TK2MSFTNGP09.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(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
>
>



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**************@TK2MSFTNGP11.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%****************@TK2MSFTNGP11.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**********@planet.nl> skrev i meddelandet
news:uQ****************@TK2MSFTNGP09.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(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
>
>



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

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****************@TK2MSFTNGP11.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***@bellsouth.net> wrote in message
news:eu**************@TK2MSFTNGP10.phx.gbl...
Hi,

Wouldnt region.isvisible 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**************@TK2MSFTNGP11.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%****************@TK2MSFTNGP11.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**********@planet.nl> skrev i meddelandet
> news:uQ****************@TK2MSFTNGP09.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(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
> > >
> > >
> >
> >
>
>



Nov 21 '05 #10
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]" <Ja************@msn.com> wrote in message
news:et****************@TK2MSFTNGP15.phx.gbl...
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

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****************@TK2MSFTNGP11.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***@bellsouth.net> wrote in message
news:eu**************@TK2MSFTNGP10.phx.gbl...
Hi,

Wouldnt region.isvisible 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**************@TK2MSFTNGP11.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%****************@TK2MSFTNGP11.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**********@planet.nl> skrev i meddelandet
> news:uQ****************@TK2MSFTNGP09.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(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
> > >
> > >
> >
> >
>
>



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

Wouldnt region.isvisible 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**************@TK2MSFTNGP11.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%****************@TK2MSFTNGP11.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**********@planet.nl> skrev i meddelandet
news:uQ****************@TK2MSFTNGP09.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(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
>
>



Nov 21 '05 #12
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:ee****************@TK2MSFTNGP11.phx.gbl...
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]" <vb***@bellsouth.net> wrote in message
news:eu**************@TK2MSFTNGP10.phx.gbl...
Hi,

Wouldnt region.isvisible 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**************@TK2MSFTNGP11.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%****************@TK2MSFTNGP11.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**********@planet.nl> skrev i meddelandet
> news:uQ****************@TK2MSFTNGP09.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(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
> > >
> > >
> >
> >
>
>



Nov 21 '05 #13
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]" <Ja************@msn.com> wrote in message
news:OL****************@TK2MSFTNGP15.phx.gbl...
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:ee****************@TK2MSFTNGP11.phx.gbl...
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]" <vb***@bellsouth.net> wrote in message
news:eu**************@TK2MSFTNGP10.phx.gbl...
Hi,

Wouldnt region.isvisible 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**************@TK2MSFTNGP11.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%****************@TK2MSFTNGP11.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**********@planet.nl> skrev i meddelandet
> news:uQ****************@TK2MSFTNGP09.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(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
> > >
> > >
> >
> >
>
>



Nov 21 '05 #14

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

Similar topics

6
by: Paul Kaufman | last post by:
What do I add to the style sheet to do this? Thanks. -Paul, the CSS Newbie
4
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...
0
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...
4
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...
4
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...
1
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...
3
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...
5
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...
5
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.