在你的Form1放一个Timer(Interval=100),一个LabelPrivate Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As LongPrivate Const GWL_EXSTYLE = (-20)
Private Const GWL_HINSTANCE = (-6)
Private Const GWL_HWNDPARENT = (-8)
Private Const GWL_STYLE = (-16)Private Type POINTAPI
x As Long
y As Long
End TypeDim gHwnd As Long
Private Sub Timer1_Timer()
Dim Pt As POINTAPI
Dim ClassName As String
Dim tmp As Long
Call GetCursorPos(Pt)
wnd = WindowFromPoint(Pt.x, Pt.y)
If wnd <> gHwnd Then
Label1.Caption = "hWnd:" & wnd
ClassName = String$(256, " ")
GetClassName wnd, ClassName, 255
ClassName = Left$(ClassName, InStr(ClassName, vbNullChar) - 1)
Label1.Caption = Label1.Caption & vbCrLf & "类名:" & ClassName
tmp = GetWindowLong(wnd, GWL_STYLE)
Label1.Caption = Label1.Caption & vbCrLf & "Style:" & tmp & " (&&H" & Hex(tmp) & ")"
tmp = GetWindowLong(wnd, GWL_EXSTYLE)
Label1.Caption = Label1.Caption & vbCrLf & "ExStyle:" & tmp & " (&&H" & Hex(tmp) & ")"
tmp = GetWindowLong(wnd, GWL_HWNDPARENT)
Label1.Caption = Label1.Caption & vbCrLf & "hWndParent:" & tmp & " (&&H" & Hex(tmp) & ")"
tmp = GetParent(wnd)
Label1.Caption = Label1.Caption & vbCrLf & "Parent:" & tmp & " (&&H" & Hex(tmp) & ")"
gHwnd = wnd
End If
End Sub
Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As LongPrivate Const GWL_EXSTYLE = (-20)
Private Const GWL_HINSTANCE = (-6)
Private Const GWL_HWNDPARENT = (-8)
Private Const GWL_STYLE = (-16)Private Type POINTAPI
x As Long
y As Long
End TypeDim gHwnd As Long
Private Sub Timer1_Timer()
Dim Pt As POINTAPI
Dim ClassName As String
Dim tmp As Long
Call GetCursorPos(Pt)
wnd = WindowFromPoint(Pt.x, Pt.y)
If wnd <> gHwnd Then
Label1.Caption = "hWnd:" & wnd
ClassName = String$(256, " ")
GetClassName wnd, ClassName, 255
ClassName = Left$(ClassName, InStr(ClassName, vbNullChar) - 1)
Label1.Caption = Label1.Caption & vbCrLf & "类名:" & ClassName
tmp = GetWindowLong(wnd, GWL_STYLE)
Label1.Caption = Label1.Caption & vbCrLf & "Style:" & tmp & " (&&H" & Hex(tmp) & ")"
tmp = GetWindowLong(wnd, GWL_EXSTYLE)
Label1.Caption = Label1.Caption & vbCrLf & "ExStyle:" & tmp & " (&&H" & Hex(tmp) & ")"
tmp = GetWindowLong(wnd, GWL_HWNDPARENT)
Label1.Caption = Label1.Caption & vbCrLf & "hWndParent:" & tmp & " (&&H" & Hex(tmp) & ")"
tmp = GetParent(wnd)
Label1.Caption = Label1.Caption & vbCrLf & "Parent:" & tmp & " (&&H" & Hex(tmp) & ")"
gHwnd = wnd
End If
End Sub
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货