FindWindowEx - Child Windows have the same name

Posted on 2006-05-15
Last Modified: 2012-05-05
How do you use findwindowex to get the hwnd of child windows with the same class name?

ParentWindow Classname: "Test"
Child Window Classname "Jackson"
Child Window Classname "Jill"
Child Window Classname "Rick"
Child Window Classname "Bob"
Child Window Classname "Rick"

How would I use findwindowex to retrieve the both child window handles with the classname of "Rick"?

I can't use a big complicated enumeration procedure, there must be a way to keep it simple using findwindowex
Question by:Hepen
    LVL 27

    Accepted Solution


    or, you can use a loop:

    dim colRicks as new collection

    hRick=FindWindowEx(hTest,0,"Rick",vbNullString) 'Find first in Z order
    Do while hRick<>0
       colRicks.Add hRick
       hRick=FindWindowEx(hTest,hRick,"Rick",vbNullString) 'Find next in Z order

    Author Comment

    You rock man! Thank you! I can't believe people use the enumeration method to do this.  

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
    Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now