views:

191

answers:

2

I have a CDHTMLDialog in a BHO that I want to be partially transparent, in the sense that the transparent area changes according to the logic of the dialog. I got it to become transparent visually (using SetLayeredWindowAttributes), but it is critical to make this region truly transparent, because otherwise when I click on the transparent region my clicks do not reach the IE window which is below the transparent part of my dialog. I temporarily fix this by constantly resizing my dialog according to the size of the active part of the dialog, but I can't keep up with this forever...

I think the solution has something to do with what windows calls "regions" (http://msdn.microsoft.com/en-us/library/dd162915%28VS.85%29.aspx) but I'm not exactly sure how to work with them. Can anyone point me in the right direction?

A: 

I found the way to make an entire window transparent and click-through here:

http://www.codeproject.com/KB/wtl/transparent.aspx

But it's not useful for my case where I only want the transparent part of my window (transparent by HTML/CSS definitions) to be click-through...

Update: Apparently, the clicks are supposed to go through the transparent parts (see http://jalaj.net/2007/02/05/form-with-a-hole/), but in my CDHTMLDialog they don't. My best guess is that a sub-window of the BHO catches my clicks, but I don't really think that makes much sense...

Neko
+1  A: 

I don't think you want to make parts of your window transparent, what you want to do is (I think) set the window region (like you mention). Read the MSDN on SetWindowRgn() - basically you define a GDI object of type HRGN (if you're using MFC, CRgn) which described a surface of a certain shape, and eventually with parts cut out. Windows then considers only the 'region' that you set on a window as the part of the window to use. Basically it's how you make non-rectangular windows. A 'region' isn't a 'transparent' part of a window, it's a way to discard areas of a window, in a way.

Roel
Sounds reasonable, though this requires that I know in advance which parts of the window are transparent. My main problem is that its dynamic HTML and the transparent parts of it change without the BHO's knowledge.
Neko
Oh I see now, yeah that makes it difficult. Actually I don't think it's possible at all. Do you have a way to know when the user clicks, and when he does whether it was on a transparent part? If so, you could just forward the WM_LBUTTONDOWN and other mouse messages to the parent window.
Roel