Torna al Thread
Public Sub New()
' This call is required by the Windows Form Designer.
InitializeComponent()
' Aggiungo l'evento MouseClick a tutti i controlli presenti sul form
For Each ctrl As Control In Me.Controls
AddHandler ctrl.MouseClick, AddressOf _MouseClick
Next
End Sub
Private Sub _MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
Dim contSel As System.Windows.Forms.Control
contSel = GetFocusedControl(MyBase.Controls)
Dim ff As String
ff = contSel.ToString
End Sub
Private Function GetFocusedControl(ByVal Controls As System.Windows.Forms.Control.ControlCollection) As System.Windows.Forms.Control
' store focused control&
For Each clsControl As System.Windows.Forms.Control In Controls
If clsControl.Focused Then
Return clsControl
End If
If clsControl.ContainsFocus Then
If (clsControl.Controls.Count = 0) Then
Return clsControl
Else
Return GetFocusedControl(clsControl.Controls)
End If
End If
Next
' no focus&
Return Nothing
End Function