[python-win32] Existing App-window ->Transparent
Mark Hammond
mhammond at skippinet.com.au
Fri Jul 9 05:45:01 CEST 2004
> I've been happily using win32gui.EnumWindows()
> to get handles of GUI windows existing applications
> running on Win2k and WinXP.
>
> I've managed to read the titlebar of various running apps windows.
> Now I'd like to change the background color of that window
> so that it is transparent - i.e. so I can see through it to
> the window underneath it. Is this possible?
> I am no guru of MFC,COM etc - so I'd appreciate any existence proofs.
>
> I've tried - without joy - this :
>
> ...
> dc = win32ui.CreateDCFromHandle(handle)
> try:
> dc.SetBkMode(win32con.TRANSPARENT)
> dc.RestoreDC()
> except Exception, e:
> print "dc.SetBkMode(win32con.TRANSPARENT) failed", e
>
> But my ignorance of the Windows API
I'm not 100% sure, but I think you will be pushing poo uphill. Code similar
to yours will exist in the other application's code - ie, as the other app
receives a WM_PAINT message, it will setup the DC context and mode itself
before doing the drawing.
For apps that have very simple painting, and do not handle WM_ERASEBKGRND,
you *may* be able to tweak the window class, as Windows itself then does the
background paint, but I doubt you will find something that works for every
app.
Mark
More information about the Python-win32
mailing list