鼠标悬停在圆形区域? [英] Mouse Hover over round Area?

查看:64
本文介绍了鼠标悬停在圆形区域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!


我有一个圆形区域,我希望能够将鼠标移动并触发

关闭事件...怎么做我这样做了吗?


我画了一个FillPie图形,我觉得必须有一种方法可以让你知道鼠标是否结束了区域,因为我有坐标

来绘制馅饼,但我不知道从哪里开始或者到底要找什么。


最好的问候

/ Lars

Hi!

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

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

Best Regard
/Lars

推荐答案

Lars,


你有没有见过这个好看的我曾经做过的样品吗?


它应该包含你的部分问题。

(它只需要一个表格并粘贴代码)


我希望你能用它吗?


Cor


\\\制作作者:Cor Ligthert来自Herfried的想法。 K. Wagner和Fergus

Cooney

Private WithEvents button1 As New Button

私有mouseX,mouseY As Integer

私有myMouseDown为布尔值

私有子Form1_Load(ByVal发送者为System.Object,_

ByVal e As System.EventArgs)处理MyBase.Load

Dim g As New System.Drawing.Drawing2D.GraphicsPath

g.AddString(" HTH"& vbCrLf&" Cor",_

System.Drawing .FontFamily.GenericSansSerif,_

System.Drawing.FontStyle.Bold,200,_

新点(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。黑色

button1.Location =新的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发送者为对象,ByVal _
$ b $是As System.Windows.Forms.MouseEventArgs)处理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)处理MyBase.MouseMove

静态LastCursor为点

Dim NowCursor As Point = New Point(Cursor.Positio) nX,

Cursor.Position.Y)

如果Point.op_Inequality(NowCursor,LastCursor)那么

如果myMouseDown那么

Me.Location = New System.Drawing.Point(Cursor.Position.X _

- mouseX,Cursor.Position.Y - mouseY)

结束如果

LastCursor = Cursor.Position

结束如果

End Sub

Private Sub Form1_MouseUp(ByVal sender As Object,ByVal e as _

System.Windows.Forms.MouseEventArgs)处理MyBase.MouseUp

myMouseDown = False

End Sub

///

" Lars Netzel" < [stop_spam] @ host.topdomain>
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>
嗨!

我有一个圆形区域,我希望能够移动鼠标并且
fire关闭事件...我该怎么做?

我画了一个FillPie图形,我觉得必须有一种方法来了解鼠标是否在该区域之上因为我有
坐标来绘制Pie,但我不知道从哪里开始或者想要寻找

最好的问候
/ Lars
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



是的,它有助于理解如何获得鼠标的位置

光标并与该op_Inequality进行比较但是我不知道如何获得

的位置来比较...我的意思是,如果我有鼠标顾客..我需要

循环通过所有圆形区域内的点数然后运行op_inequality

测试,以及如何获得该区域的积分......?


/ Lars



" Cor Ligthert <无********** @ planet.nl> skrev i meddelandet

新闻:uQ **************** @ TK2MSFTNGP09.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,

您有没有看过我曾经做过的这个好样品?

它应该包含您的部分问题。
(它只需要一个表格和粘贴代码中)

我希望你能用它吗?

Cor Ligthert的Cor

\\\\来自Herfried。 K. Wagner和
Fergus Cooney
Private WithEvents button1作为新按钮
私有mouseX,mouseY作为整数
私有myMouseDown作为布尔值
Private Sub Form1_Load(ByVal sender As System .Object,_
ByVal e As System.EventArgs)处理MyBase.Load
Dim g As New System.Drawing.Drawing2D.GraphicsPath
g.AddString(" HTH"& vbCrLf& ;Cor,_
System.Drawing.FontFamily.GenericSansSerif,_
System.Drawing.FontStyle.Bold,200,_
新点(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)处理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)处理MyBase .MouseMove
静态LastCursor As Point
Dim NowCursor As Point =新点(Cursor.Position.X,
Cursor.Position.Y)
如果Point.op_Inequality(NowCursor,LastCursor)那么
如果myMouseDown那么
Me.Location =新系统.Drawing.Point(Cursor.Position.X _
- mouseX,Cursor.Position.Y - mouseY)
结束如果
LastCursor = Cursor.Position
结束如果
End Sub
Private Sub Form1_MouseUp(ByVal sender As Object,ByVal e As _
System.Windows.Forms.MouseEventArgs)处理MyBase.MouseUp
myMouseDown = False
End Sub
///

" Lars Netzel" < [stop_spam] @ host.topdomain>
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

<消防

关闭事件...我该怎么做?

我画了一个FillPie图形,我觉得必须有一种方法知道鼠标是否在那个区域之上,因为我有
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


坐标

来绘制Pie,但我不知道从哪里开始或者什么到真的找
to paint the Pie but I don''t know where to start or what to look for



最好的问候
/ Lars

Best Regard
/Lars




没有答案比这更容易。

你占据客户区的中心并计算。


例如,如果半径为10,则客户区域为20,20。然后

中心点是10,10。如果x或y大于中心点+或 -

鼠标坐标那么这就出来了


或者计算任何给定点的斜边

H * H = A * A + O * O


一旦计算出H = SQRT(A * A + O * O)就可以比较这个反对

半径。确定该点是否在。


-


OHM(特里伯恩斯)

。 。 。单手人。 。

如果你需要我的电子邮件,请问我


当你不知道自己在做什么时,过得很快


" Lars Netzel"百分比抑制率stop_spam] @ host.topdomain>在消息中写道

新闻:O%**************** @ 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...
是的,它有助于理解如何获得鼠标的位置光标并与op_Inequality进行比较,但我不确定如何获得
位置与...进行比较...我的意思是,如果我有mouseCursor ..我是否需要
来循环到Round Area中的所有点然后运行op_inequality
测试,以及如何获得该区域的积分......?br />
/ Lars


Cor Ligthert <无********** @ planet.nl> skrev i meddelandet
新闻:uQ **************** @ TK2MSFTNGP09.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,
<你有没有看过我曾经做过的这个好样本?

它应该包含你的部分问题。
(它只需要一个表格并粘贴代码)

我希望你能用它吗?

Cor Ligthert来自Herfried的想法。 K. Wagner和
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


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)处理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.SystemColor s.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)
结束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 _
As 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)处理MyBase.MouseMove
静态LastCursor As点
Dim NowCursor As Point =新点(Cursor.Position.X,
Cursor.Position.Y)
如果Point.op_Inequality(NowCursor,LastCursor)那么
如果myMouseDown然后
Me.Location = New System.Drawing.Point(Cursor.Position.X
_ - mouseX,Cursor.Position.Y - mouseY)
结束如果
LastCursor = Cursor。位置
结束如果
End Sub
Private Sub Form1_MouseUp(ByVal sender As Object,ByVal e As _
System.Windows.Forms.MouseEventArgs)处理MyBase.MouseUp
myMouseDown = False
End Sub
///

" Lars Netzel" < [stop_spam] @ host.topdomain>
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

<消防

关闭事件......我该怎么做?

我画了一个FillPie图形,我觉得必须有一个方法
了解鼠标是否在该区域上方,因为我有
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


坐标

来绘制饼图,但我不知道从哪里开始或者什么到真的找
to paint the Pie but I don''t know where to start or what to look for



最好的问候
/ Lars

Best Regard
/Lars





这篇关于鼠标悬停在圆形区域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆