4
votes

I'm working with a Win32 application that needs to create a variety of custom window types. In particular, these windows are often non-rectangle, have shadows, or are mostly transparent.

I'm currently using WS_EX_LAYERED with UpdateLayeredWindow to create transparent windows that I can then draw my arbitrary graphics on. However, I find layered windows to be limiting in that you can't have layered child windows, nor can a layered window properly host 'normal' Win32 controls.

Our code base is several years old, using mostly Win32 and GDI, but we're in the process of modernizing things and it's time to look at newer technologies.

I've considered doing my custom windowing in WPF, but I'm concerned about what I've read about 'airspace' issues. It seems that WPF uses layered windows to accomplish its per-pixel alpha blending and so seems like it would also suffer from the limitations I've previously experienced.

I don't know much (anything, really) about Direct2D, but that technology sounds like it might be interesting. Though, I can't find any references to it being able to do overlay windows.

So, all of this brings me to my problem: What's the best technology for doing overlay windows under Windows? (Vista and Win7 at a minimum, XP would be nice to have)

Am I neglecting some, particularly good technology? Any suggestions would be appreciated.

2

2 Answers

2
votes

I recommend Direct2D and DirectWrite as you get high-quality rendering that's also ridiculously fast compared to either GDI or anything done in the .Net space. The only problem is that you need Vista or later OS to use it.

4
votes

WPF can do what you are looking for very easily, but, this particular feature of WPF (windows with per-pixel transparency) tends to be very problematic due to graphics drivers bugs (apparently graphic hardware manufacturers don't test layered Direct3D windows with per pixel alpha value very well).

WPF does use layered windows for transparency, but it does not use "normal" win32 controls, all the wpf controls in a window render them self using just one win32 window, they all support transparency.

The "airspace" issue only happens when you host a WinForms control inside a WPF window.