I know how to make my own application transparent using Layered Windows but I want to make a different application transparent (for example notepad).
I wrote code like this but it doesn’t work with other windows except my app main window:
SetWindowLongPtr(WindowFromPoint(p), GWL_EXSTYLE,
GetWindowLongPtr(hWnd, GWL_EXSTYLE) | WS_EX_LAYERED);
SetLayeredWindowAttributes(WindowFromPoint(p), 0, (255 * 50) / 100, LWA_ALPHA);
where p is a point on screen ( for example the window I select with my mouse )
I am also interested if there is a way to do this directly from Windows 7 (not necessarily programmatic). I figure there must be a way to do it since every application is rendered in it’s own surface and DWM composites them into the final image.
You are using a different window handle for
SetWindowLongPtrthan the one you use forGetWindowLongPtris that a bug in your code or just a typo in your question?The following code works for me on Windows Server 2003 and on Windows 7
However, it only works if WindowFromPoint returns the top level window for the application, if it returns a child window, then the code doesn’t work. So it works when the mouse is over the caption of the window I want to make transparent, but usually not anywhere else.
(tested with notepad)