Public Sub ForegroundWindow(ByVal hwnd As Long)
Dim lForeThreadID As Long
Dim lThisThreadID As Long
Dim lReturn As Long
If hwnd <> GetForegroundWindow() Then
If IsIconic(hwnd) Then
Call ShowWindow(hwnd, SW_RESTORE)
Else
ShowWindow hwnd, SW_MINIMIZE
Call ShowWindow(hwnd, SW_SHOW)
End If
lForeThreadID = GetWindowThreadProcessId(GetForegroundWindow, ByVal 0&)
lThisThreadID = GetWindowThreadProcessId(hwnd, ByVal 0&)
If lForeThreadID <> lThisThreadID Then
Call AttachThreadInput(lForeThreadID, lThisThreadID, True)
lReturn = SetForegroundWindow(hwnd)
Call AttachThreadInput(lForeThreadID, lThisThreadID, False)
Else
lReturn = SetForegroundWindow(hwnd)
End If
End If
End Sub
Сейчас этот форум просматривают: AhrefsBot, Yandex-бот и гости: 80