How to get device context for com object?

Walter Miller wmiller at
Tue Feb 20 23:03:22 CET 2001

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.

"Alex Martelli" <aleaxit at> wrote in message
news:96ujcc12r6k at
> "Walter Miller" <wmiller at> wrote in message
> news:NVxk6.15$uj7.15036 at
> > Anyone know how to get a device context for a com object?  For example:
> There is no general way: the COM object might have/use any
> number of windows, from 0 upwards, at any given time, and/or
> other devices, so it's not clear at all what 'a device context for
> the object' might mean (what does it mean to get a device
> context for a process, or a thread, or a DLL, or...?).
> Some specific COM interface for which it makes sense will
> implement a GetDC method, of course (offhand, though, only
> IDirectDrawSurface3 comes to mind -- which doesn't help
> you much with an internet explorer application object!-)
> Other will let you get a handle to a window object (again
> only one comes to mind, IOleWindow, but that one has
> several derivatives, and is used heavily in the in-place
> activation protocol, so it _may_ be possible, with a little
> bit of effort, to get *that* one for internet explorer -- if
> you activate it in-place within a container of yours, or use
> it as the container for your own activex control's in-place
> activation).
> Alex

More information about the Python-list mailing list