Holas gente ... una duda ...como puedo saber q ventana(cualquier ventana de windows) tiene el foco???...osea la ventana q tiene su barra de titulo de color azul...y q un msgbox me diga el nombre de la ventana q actualmente tiene el foco
Una ventana tiene el foco cuando estamos en ella xq iniciamos el prog o por q la restauramos o maximizamos despues de estar minimizada en la barra de tareas
Private Declare Function GetForegroundWindow Lib "user32" () As Long Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Sub Form_Load() Timer1.Interval = 100 End Sub
Private Sub Timer1_Timer() Static lHwnd As Long Dim lCurHwnd As Long Dim sText As String * 255 lCurHwnd = GetForegroundWindow If lCurHwnd = lHwnd Then Exit Sub lHwnd = lCurHwnd If lHwnd <> hwnd Then Caption = "Ventana Activa: " & Left$(sText, GetWindowText(lHwnd, ByVal sText, 255)) Else Caption = "Ventana Activa: Form1" End If End Sub