求将以下C代码转成VB代码
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type PGUITHREADINFO
cbSize As Long
flags As Long
hWndActive As Long
hwndFocus As Long
hwndCapture As Long
hwndMenuOwner As Long
hwndMoveSize As Long
hwndCaret As Long
rcCaret As RECT
End Type
Private Declare Function AttachThreadInput Lib "user32" (ByVal idAttach As Long, ByVal idAttachTo As Long, ByVal fAttach As Long) As Long
Private Declare Function GetForegroundWindow Lib "user32" () As Long
Private Declare Function GetCurrentThreadId Lib "kernel32" () As Long
Private Declare Function GetGUIThreadInfo Lib "user32" (ByVal idThread As Long, ByRef pgui As PGUITHREADINFO) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Function GetKeyFocusWnd() As Long
Dim hwnd As Long
Dim dwTargetThreadID As Long
Dim dwCurrentThreadID As Long
Dim bRetVal As Boolean
Dim sThreadInfo As PGUITHREADINFO
hwnd = GetForegroundWindow
dwTargetThreadID = GetWindowThreadProcessId(hwnd, vbNull)
dwCurrentThreadID = GetCurrentThreadId
bRetVal = AttachThreadInput(dwCurrentThreadID, dwTargetThreadID, True)
sThreadInfo.cbSize = Len(sThreadInfo)
bRetVal = GetGUIThreadInfo(dwTargetThreadID, sThreadInfo)
Dim hTargetWnd As Long
hTargetWnd = hwnd
If sThreadInfo.hwndFocus Then
hTargetWnd = sThreadInfo.hwndFocus
ElseIf sThreadInfo.hWndActive Then
hTargetWnd = sThreadInfo.hWndActive
End If
AttachThreadInput dwCurrentThreadID, dwTargetThreadID, False
GetKeyFocusWnd = hTargetWnd
End Function
爱资源吧版权声明:以上文中内容来自网络,如有侵权请联系删除,谢谢。