Results 1 to 2 of 2

Thread: Enumerating Windows

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 1999
    Location
    Cleveland, Ohio
    Posts
    263
    Ok, two things:

    1. There's an example of how to find all of the available windows using the GetWindow API. I read that this can cause an infinite loop if used in a loop because of a 'destroyed window', so it's better to use EnumChildWindows or something. Could someone show me how this EnumChildWindows works? I looked it up but it's not helpful to me.

    2. How would I enumerate all of the children of a parent (including buttons, listboxes, etc.)? By this I only mean the direct children, not list all children, such as the child of a child of a parent. If that last line confused you ignore it.

    Thanks in advance.

    [Edited by Phobic on 03-20-2000 at 09:19 PM]

  2. #2
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    The easyist way of getting a windows Siblings is to use it's parent controls.

    make a new usercontrol and put the following code in it

    Code:
    Public property get Siblings as collection
    
    Siblings = usercontrol.parentcontrols
    
    end property
    then the siblings property will give you all the controls with the same parent as your control in a collection.

    the enumchildwindows API is a callback function.

    First Create a new function in a standard module, declare it something like this
    Code:
    public Function EnumChildWindowsProc(byval hWnd as long, _  
                                         byval lParam as long) _
                                         as Long
    when you call the enumchildwindows function call it like

    Code:
    EnumChildWindows hWnd,addressof EnumChildwindowsProc,lParam
    where hWnd is the window you want the children of and lParam is a long integer you can use to Identify the window you're calling, you can set it to the window handle of the parent window or anything else you want.

    If you return a non 0 value from enumchildwindowproc windows will keep calling the procedure with the window handle of all the child windows. I dont know if it does grandchildren or not, Have a play.

    Hope this helps

    [

    [Edited by Sam Finch on 03-20-2000 at 09:50 PM]

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