您的位置:首页 > 编程语言 > VB

[VB.NET]我想判断光标是否在A控件上,在就触发一个事件,没在也触发一个事件,请各位高人想个办法,在线等待

2008-12-26 23:25 543 查看



<script type="text/javascript"><!--
google_ad_client = "pub-8333940862668978";
/* 728x90, 创建于 08-11-30 */
google_ad_slot = "4485230109";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

我想判断光标是否在A控件上,在就触发一个事件,没在也触发一个事件,请各位高人想个办法,在线等待
我想判断光标是否在A控件上,在就触发一个事件,没在也触发一个事件,请各位高人想个办法,在线等待
__________________________________________________________________________
LostFocus和GotFocus
__________________________________________________________________________
private void button1_Click(object sender, EventArgs e)
{
Timer timer = new Timer();
timer.Interval = 200;
timer.Tick += new EventHandler(timer_Tick);
timer.Start();
}

void timer_Tick(object sender, EventArgs e)
{
Control tmp = this.GetChildAtPoint(this.PointToClient(Cursor.Position));
if (tmp != null)
{
Console.WriteLine( "鼠标在控件{0}之上. ", tmp);
}
}
__________________________________________________________________________
VB.NET代码:
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim timer As New Timer
timer.Interval = 200
AddHandler timer.Tick, New EventHandler(AddressOf Me.timer_Tick)
timer.Start
End Sub

Private Sub timer_Tick(ByVal sender As Object, ByVal e As EventArgs)
Dim tmp As Control = MyBase.GetChildAtPoint(MyBase.PointToClient(Cursor.Position))
If (Not tmp Is Nothing) Then
Console.WriteLine( "鼠标在控件{0}之上. ", tmp)
End If
End Sub
__________________________________________________________________________
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  vb.net timer object button null
相关文章推荐