[python-win32] win32gui.EnumWindows, documentation?

Tim Roberts timr at probo.com
Wed Mar 12 00:13:45 CET 2008

Julius wrote:
> My fault(already got that one running), i meant the 
> win32gui.EnumChildWindows(currentHwnd, windowEnumerationHandler,
> childWindows)
> function.
> from what i understand the purpose of this function is to return the
> childwindows from a top window - if this is right why not just pass a
> topwindow as argument and return a list of childwindows?

Windows APIs don't ever return lists of things, because it present a 
memory management difficulty.  Who allocates, who owns, who releases, 
etc.  Instead, they all use the "enumeration callback" concept.  That 
way, if you want a list, you can construct and maintain it yourself.

If you just want the list of handles, you can do something like this:
    childlist = []
    win32ui.EnumChildWindows( hwnd, lamba hwnd,oldlist: oldlist.append( 
hwnd ), childlist )

Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.

More information about the python-win32 mailing list