Results 1 to 5 of 5

Thread: Active Window of Desktop

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2000
    Posts
    71

    Question

    Is it possible to obtain the all handles of the child windows of the active window (window in focus) in the desktop ?

  2. #2
    PowerPoster
    Join Date
    Aug 2000
    Location
    India
    Posts
    2,288
    "FindWindowEx" api call does return handle all windows includng the child windows. Use this api call to collect all the hwnd's. Use the "GetParent" Api call to know which window is a child of the currently active window.
    Last edited by amitabh; Feb 2nd, 2001 at 11:03 AM.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 2000
    Posts
    71

    Question

    Hi , can you show me the code because i am new to api programming .

    Originally posted by amitabh
    "FindWindowEx" api call does return handle all windows includng the child windows. Use this api call to collect all the hwnd's. Use the "GetParent" Api call to know which window is a child of the currently active window.

  4. #4
    PowerPoster
    Join Date
    Aug 2000
    Location
    India
    Posts
    2,288
    Sorry. I am on a computer wich doesnot have VB and will not be on one until the next couple of days.

    Look at www.vbapi.com/ref/f/findwindowex.html and www.allapi.net for futher refrence. vbapi.com has some excellent tutorials on using api in VB. If you are new to api's, you can stick to what Vlatko has written.

  5. #5
    Guest
    Add to a Module.
    Code:
    Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
    Declare Function EnumWindows Lib "user32.dll" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
    
    Public Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
        Dim Length As Long
        Dim sName As String
        Dim Temp As String
        Static iCount As Integer
        
        iCount = iCount + 1
        Length = GetWindowTextLength(hwnd) + 1
        
        If Length > 1 Then
          sName = Space(Length)
          GetWindowText hwnd, sName, Length
          Debug.Print Left(sName, Length - 1) & " - " & hWnd
        End If
        
        EnumWindowsProc = 1
    End Function
    Add to a Form
    Code:
    Private Sub Command1_Click()
        EnumWindows AddressOf EnumWindowsProc, 0
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width