tags:

views:

134

answers:

3

I'm making a non-rectangular dialog, modelled over an image from Photoshop (the image is the background of the dialog, and the user will see trough the transparent part of the image). I'ts like a dashboard-style window for a media-app with a few custom-drawn controls. Most of the background-image is either opaque or 100% transparent - but in between there is a thin area of partially transparent pixels, ment to blend the image smootly into the background. This works great for web-graphics, but I have not found a way to make this work for Windows windows. I'm using the Windows Template Library (WTL), msvc 2008 - and the app must run on Windows XP as well as Vista and Windows 7.

Currently, I'm simply using the opaque part of the background-image to create a GDI clipping-region, but this gives pretty rough edges.

Does anyone know about any API functions to accomplish this (part of WTL, or reachable from WTL)?

A: 

Not sure how this interoperates with WTL, but have a look at the AlphaBlend function. You'll need to select your partially transparent bitmap into a DC and copy that to your dialog's DC in your paint function.

Mark Ransom
AlphaBlend() works fine from WTL, but I'm unable to blend transparently to the background of my application-window.
jgaa
A: 

Perhaps you could use layered windows? I haven't tested these with WTL but you should be able to get the effect you want. To the best of my knowledge I don't think you can add controls to a layered window so you'll need to attach it to another (non-layered) window to use controls.

Ron Warholic
I tried layered windwos with WS_EX_LAYERED style in another project, and it turned out that I could fade the window out and in, but the per-pixel blending worked in a boolean way. Each pixel was either visible or not. Direct2D may work, bit afaik it's not available for Windows XP.
jgaa
I've used layered windows explicitly to make an alpha-blended (shadowed) form before without problems. Alain has a link to using WTL with the layered window style, check that out.
Ron Warholic
A: 

This article shows how to use layered windows with WTL and the Gdi+ API which is available on all your target platforms.

Alain Rist