我想判断光标是否在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 __________________________________________________________________________