vb6 api 如何使用ChildWindowFromPoint或者ChildWindowFromPointEx获取已禁用的控件的句柄
展开全部
Private Declare Function GetForegroundWindow Lib "user32" () As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Declare Function GetFocus Lib "user32" () As Long
Private Declare Function AttachThreadInput Lib "user32" (ByVal idAttach As Long, ByVal idAttachTo As Long, ByVal fAttach As Long) As Long
Public Function GetHwnd() As Long
Dim hwnd As Long
Dim PID As Long
Dim TID As Long
Dim hWndFocus As Long
hwnd = GetForegroundWindow
If hwnd Then
TID = GetWindowThreadProcessId(hwnd, PID)
AttachThreadInput App.ThreadID, TID, True
GetHwnd = GetFocus
AttachThreadInput App.ThreadID, TID, False
End If
End Function
Private Sub Command1_Click()
GetHwnd
MsgBox hwnd
End Sub
Private Sub Form_Load()
Call Command1_Click
End Sub
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Declare Function GetFocus Lib "user32" () As Long
Private Declare Function AttachThreadInput Lib "user32" (ByVal idAttach As Long, ByVal idAttachTo As Long, ByVal fAttach As Long) As Long
Public Function GetHwnd() As Long
Dim hwnd As Long
Dim PID As Long
Dim TID As Long
Dim hWndFocus As Long
hwnd = GetForegroundWindow
If hwnd Then
TID = GetWindowThreadProcessId(hwnd, PID)
AttachThreadInput App.ThreadID, TID, True
GetHwnd = GetFocus
AttachThreadInput App.ThreadID, TID, False
End If
End Function
Private Sub Command1_Click()
GetHwnd
MsgBox hwnd
End Sub
Private Sub Form_Load()
Call Command1_Click
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询