[python-win32] Existing App-window ->Transparent

Moore, Paul Paul.Moore at atosorigin.com
Fri Jul 9 10:16:24 CEST 2004


There are window styles WS_EX_LAYERED and WS_EX_TRANSPARENT, and a SetLayeredWindowAttributes call which are probably relevant. I have an application, Windows PowerPro, which among, other functions, can set arbitrary windows to have a transparency of anything between 0 (opaque) and 255 (completely invisible). I don't know how it works, exactly, but playing with it (www.windowspowerpro.com) and something like Spy++ might give some ideas...

Paul.

-----Original Message-----
From: python-win32-bounces at python.org
[mailto:python-win32-bounces at python.org]On Behalf Of Mark Hammond
Sent: 09 July 2004 04:45
To: 'Gavin Brelstaff'; python-win32 at python.org
Subject: RE: [python-win32] Existing App-window ->Transparent


> 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

_______________________________________________
Python-win32 mailing list
Python-win32 at python.org
http://mail.python.org/mailman/listinfo/python-win32


__________________________________________________________________________
This e-mail and the documents attached are confidential and intended 
solely for the addressee; it may also be privileged. If you receive this 
e-mail in error, please notify the sender immediately and destroy it.
As its integrity cannot be secured on the Internet, the Atos Origin group 
liability cannot be triggered for the message content. Although the 
sender endeavours to maintain a computer virus-free network, the sender 
does not warrant that this transmission is virus-free and will not be 
liable for any damages resulting from any virus transmitted.
__________________________________________________________________________


More information about the Python-win32 mailing list