How to get device context for com object?

Alex Martelli aleaxit at yahoo.com
Tue Feb 20 17:44:51 EST 2001


"Walter Miller" <wmiller at mediaone.net> wrote in message
news:YQBk6.80$3e2.62458 at news.pacbell.net...
> The "InternetExplorer.Application.1" com object has a HWND property from
> which you can get the window handle.  It seem reasonable to expect that
one
> could get a device context based on a valid window handle.

If you have a valid window handle, you can indeed get a device
context for that window -- that's got nothing to do with COM (or
however else you got your HWND), but rather is the job of the APIs
GetWindowDC (if you want the DC for the _entire_ window, i.e.,
including the non-client areas), GetDC (if you want the DC for
the client-area only), GetDCEx (if you want peculiar clipping, a
cached context, and/or intact DC attributes... THAT one I've never
used yet!-), ... -- just call the appropriate one (at least the first
two, I believe, are exposed by modules in the win32all package).


Alex






More information about the Python-list mailing list