Listar Ventanas, problemas con IDEOwner

Iniciado por LeandroA, 12 Mayo 2009, 08:09 AM

0 Miembros y 2 Visitantes están viendo este tema.

LeandroA

hola, tengo un problema con este codigo, estoy listando todas las ventanas que aparecen en la barra de Tareas, y cuando le doy clic en el list me imprime la ventana, pero el problema es con el IDE de visual basic si no esta minimizado, el problema es que la ventana se llama wndclass_desked_gsk pero la que en realidad el que tiene el ExStyle WS_EX_APPWINDOW es IDEOwner como puedo obtener la ventana wndclass_desked_gsk  a partir de IDEOwner


en un modulo
Option Explicit
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hWnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Private Declare Function GetParent Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function IsWindowVisible Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Public Declare Function PrintWindow Lib "user32.dll" (ByVal hWnd As Long, ByVal hdcBlt As Long, ByVal nFlags As Long) As Long

Private Const GWL_EXSTYLE As Long = -20
Private Const WS_EX_APPWINDOW As Long = &H40000
Private Const WS_EX_WINDOWEDGE As Long = &H100&

Dim arr() As Long

Public Function fEnumWindows() As Variant
    ReDim arr(0)
    Call EnumWindows(AddressOf fEnumWindowsCallBack, GetDesktopWindow)
    fEnumWindows = arr
End Function

Private Function fEnumWindowsCallBack(ByVal hWnd As Long, ByVal lParam As Long) As Long
    If IsWindowVisible(hWnd) Then
        If IsExStyle(hWnd, WS_EX_APPWINDOW) Or GetWinClassName(hWnd) = "CabinetWClass" Then
            arr(UBound(arr)) = hWnd
            ReDim Preserve arr(UBound(arr) + 1)
        End If
    End If
fEnumWindowsCallBack = True
End Function

Public Function GetWinText(ByVal hWnd As Long)
    Dim MyStr As String
    MyStr = String(100, Chr$(0))
    GetWindowText hWnd, MyStr, 100
    GetWinText = Left$(MyStr, InStr(MyStr, Chr$(0)) - 1)
End Function

Public Function GetWinClassName(hWnd As Long) As String
    Dim lpClassName As String
    Dim Ret As Long
    lpClassName = Space(256)
    Ret = GetClassName(hWnd, lpClassName, 256)
    GetWinClassName = Left$(lpClassName, Ret)
End Function

Private Function IsExStyle(hWnd As Long, ExStyle As Long) As Boolean
    IsExStyle = (GetWindowLong(hWnd, GWL_EXSTYLE) And ExStyle) = ExStyle
End Function



en un formulario con un picture1 y un list1

Option Explicit
Dim MyArr() As Long
'wndclass_desked_gsk
'IDEOwner
Private Sub Form_Load()
    Dim i As Long
   
    MyArr = fEnumWindows
   
    For i = 0 To UBound(MyArr) - 1
        List1.AddItem GetWinText(MyArr(i))
    Next
End Sub

Private Sub List1_Click()
    Picture1.Cls
    PrintWindow MyArr(List1.ListIndex), Picture1.hDC, 0
    Me.Caption = GetWinClassName(MyArr(List1.ListIndex))
End Sub


Creo que deberia utlizar GetWindowThreadProcessId pero no encotre forma de hacerlo.

Saludos


LeandroA

Solucionado

es con GetLastActivePopup

Saludos