[Tutor] WIn32 extension -= exposing methods with a windows handle

Alan Gauld alan.gauld at btinternet.com
Sat Jun 21 23:35:11 CEST 2008

"Mike Meisner" <mikem at blazenetme.net> wrote i

> obtain a handle to the chat box.  At that point, I don't see any
> apparent win32 functions to expose the methods available in
> the chat box and, thereby, extract the chat text information I need.

It depends on the exact type of the dialog box.
You can get the list of methods in the Pythonwin documentation,
based on the Win32 API help.

> (Since the window is not a Python generated window,
> __dict__ doesn't work, or I am incorrectly using it:
> w = CreateWindowFromHandle(hwnd); print w.__dict__).

Thats the right way to get a Python variable referencing it.

> Also, if I know that a particular method is supported by
> the window's class (e.g., GetText), can I use the window's
> handle to access the method (i.e., text =  hwnd.GetText) ?

No, you need to do what you did above and get a variable
referencing the object so you could do w.GetText(....)
- except I don't see GetText as a method of any Windows
object I've looked at.

Do you know what kind of Window object it is?
The object browser in Pytonwin might be able to tell you...
but I've never used it so don't really know!!

Alan G. 

More information about the Tutor mailing list