views:

954

answers:

4

I want to create a completely transparent window with MFC, but I don't know how to do this. Can you tell me the way?

Thank you very much!

A: 

By transparent I assume you mean invisible, not translucent. You can set the window's region to an empty region. Take a look at SetWindowRgn and the Region Functions in the Win32 API. There may be some equivalent MFC classes and methods (e.g. CRgn) if you want to avoid pure Win32 calls.

fbonnet
A: 

If you really want invisible, then you can simply clear the WS_VISIBLE bit in the windowstyle. Override PreCreateWindow and ensure this flag is cleared.

Alternatively, you can create a window that only processes messages by specifying HWND_MESSAGE as the parent hwnd in the CreateWindow calls.

adzm
+1  A: 

You can use layered windows for transparency effects. See http://msdn.microsoft.com/en-us/library/ms997507.aspx. Be sure to set the WS_EX_LAYERED bit and to use UpdateLayeredWindow. This allows you to trap messages even though the window isn't visible to the user.

unistudent
A: 

If its transparent (invisible) then how would you even know its there ?

Jobo