焦点控件的hwnd 并不是鼠标所在控件的hwnd!!
help!

解决方案 »

  1.   


    Dim a As Long
    on error resume next
    a = Me.ActiveControl.hWnd
      

  2.   

    Option Explicit
    Private Declare Function GetFocus Lib "user32" () As Long
    Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As LongPrivate Sub Timer1_Timer()
        On Error Resume Next
        Dim s As String * 50
        Dim hwnd As Long, l As Long
        hwnd = GetFocus
        l = GetWindowText(hwnd, s, 50)
        Debug.Print Left$(s, l)
    End Sub