Solved

Clipping a Layered Window

Posted on 2006-06-30
2
554 Views
Last Modified: 2013-11-20
I have a layered pop-up window which contains several child dialogs.  the children should not be of concern to this question.  The outer corners of the pop-up are rounded, I have been using standard windows clipping regions to clip them however they produc a somewhat undesired jagged edge (no anti-aliasing).  If I make the region big enough to show the anti-aliased corner I get a crappy border around the pop-up (and you can still see the pixelation in it).  It is my understanding that the color-key of a layered window defines a color that will not be rendered to the desktop (transparent).  

I use SetLayeredWindowAttributes() to fade the popup in and out.  This works very well, so the function calls are being made.

In OnPaint(), I use GDI+ Graphics::Clear() to set the entire background to the desired 'transparent' color, I then procede to draw the pop-ups frame and interior.  But when it's all done, the transparent color is not very transparent (doesn't work).

// initial set layered window in the override of CreateEx() (after everything is created and verified)
// dont mind the '0' alpha, the pop-up initially fades in
SetLayeredWindowAttributes(RGB(0,0,255),0,LWA_COLORKEY|LWA_ALPHA);

So... ... How do I get my pop-up edges 'smoothly' transparent?

Thank you in advance.
0
Comment
Question by:r2far
  • 2
2 Comments
 
LVL 22

Accepted Solution

by:
mahesh1402 earned 300 total points
ID: 17019336
>>How do I get my pop-up edges 'smoothly' transparent?

UpdateLayeredWindow() has the additional advantage that the image defining the window shape can have per-pixel transparency.  Each pixel has an alpha value of 0-255, from total transparency (invisible) to total opacity..

UpdateLayeredWindow() allows you to gradually make the  edge of the window more and more transparent, as you move toward the edge.  This lets the edge blend into the background, no matter if the background is light or dark.  The edge is thus very smooth and non-pixellated.

Have a look at this article :
Per Pixel Alpha Blend : http://www.codeproject.com/gdi/pxalphablend.asp

-MAHESH
0
 
LVL 22

Expert Comment

by:mahesh1402
ID: 17019363
I think article above at codeproject with src is exactly what you are looking for..use UpdateLayeredWindow() and check.

-MAHESH
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
bobThere java chalenge 45 94
Separate into files by filename 12 87
string initialization in java 11 115
haveThree challenge 22 121
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question