[python-win32] win32gui.EnumWindows, documentation?

Tim Roberts timr at probo.com
Wed Mar 12 17:59:05 CET 2008


Julius wrote:
> On Tue, 2008-03-11 at 16:13 -0700, Tim Roberts wrote:
>   
>> 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 )
>>     
>
> Ok, havent tried it yet but im sure it will work.
>   

Actually, if that's really what I typed, I made a mistake.  It's 
win32gui, not win32ui.

> But why isnt there any documentation what the arguments are good for?
>   

In part, because these are simple mappings of Windows APIs.  You can go 
to MSDN to get information on the actual parameters to EnumChildWindows 
in excruciating detail.  In most cases, the mapping from the C API to 
the Python API is quite clear, and this is one such case.  The C API 
gets a top-level window handle, a callback function, and a context 
parameter.  That's exactly what the win32ui version wants.

It would be a very large effort with a very small payback to retype all 
of the Windows API documentation in Python terms.

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



More information about the python-win32 mailing list