Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DirectDraw + Layered window color key?

I'm creating a window with WS_EX_LAYERED and setting a color key to it using SetLayeredWindowAttributes(). I can verify that this color key indeed creates a transparent patch in the window by drawing a simple rect using FillRect() inside the window. This doesn't work however when I'm drawing in the window using DirectDraw. I'm creating an IDirectDrawSurface7 on the window and I'm Blt()ing some pixels to it. some of the pixels are colored with the color key, but I don't see them as transparent, they just appear in the color key.

Is there something inherent in DirectDraw surface that conflicts with layered window color keying?
When i'm setting an alpha value using SetLayeredWindowAttributes(), that seem to work fine with the DirectDraw surface and it does indeed appear translucent.

like image 711
shoosh Avatar asked Oct 31 '22 14:10

shoosh


1 Answers

I don't know if you've seen this but this paragraph from the article posted below looks kinda like what you are looking for.

The hWnd is the window handle of a window with a WS_EX_LAYERED style flag. The dwFlags parameter can have one or both of LWA_COLORKEY and LWA_ALPHA. If a LWA_COLORKEY flag is used, the crKey parameter is the transparent color key. If a LWA_ALPHA flag is used, the bAlpha parameter is the constat source alpha value. **Only top-level windows can be layered windows.**

I think its that last sentence that is the problem here. The source is a partial of a book on google books. You can read it with some code detail examples found here:

http://books.google.com/books?id=-O92IIF1Bj4C&pg=PA720&lpg=PA720&dq=WS_EX_LAYERED+%2B+DirectDraw+color+key&source=bl&ots=SyWKE3aimb&sig=DXbshrEk2tN17h7CtWdMmAkHlAo&hl=en&sa=X&ei=7_JcVKSyFMukNrumgMgB&ved=0CCkQ6AEwAg#v=onepage&q=WS_EX_LAYERED%20%2B%20DirectDraw%20color%20key&f=false

I will also include the following links that talk about a little about it, although not in nearly the same amount of detail:

http://web.cs.wpi.edu/~matt/courses/cs563/talks/cbyrd/pres3.html

http://msdn.microsoft.com/en-us/library/windows/hardware/ff567254(v=vs.85).aspx

I don't know if this will answer your question, but I hope it helps a little bit. Cheers.

like image 76
Keith Enlow Avatar answered Nov 15 '22 03:11

Keith Enlow