vb 获得当前焦点所在控件句柄
如何获取程序外的焦点所在控件句柄,GetFocus只能获取本程序的,而GetForegroundWindow只能获得焦点所在窗口的句柄,那么怎么获得程序外的窗口焦点控件的...
如何获取程序外的焦点所在控件句柄,GetFocus只能获取本程序的,而GetForegroundWindow只能获得焦点所在窗口的句柄,那么怎么获得程序外的窗口焦点控件的句柄呢?
展开
2010-02-19
展开全部
Private Declare Function GetForegroundWindow Lib "user32" () As Long
Private Declare Function GetFocus Lib "user32" () 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 Declare Function GetFocus Lib "user32" () 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
没人回答,那就我自己解决算了。
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询