A fellow by the name of Patrick Sears asked me a question about the relationship between WPF and HWNDs. I’m posting the answer here, for all to read.
“Another benefit of using vector graphics is it works well with high-resolution displays; something which is becoming a problem for the antiquated HWND technology as the resolution of display units improves.”
I read something to the same effect on another blog, basically that WPF is not HWND based. What is the basis for this statement? Windows (Vista included) itself is still HWND based, is it not? How can the operating system fundamentally render a window without an HWND?
The OS can’t render a window without an HWND. WPF uses HWNDs very sparingly. One prime example of HWNDs in WPF is the Window class. It is a normal Windows window…receiving WM_WHATEVERs just like any other window.
Saying that WPF is not based on HWNDs has meaning within a window. In Win32, MFC, WinForms, etc. every pixel in a Window was “owned” by a control. Since a control was really just another window (and a window is an HWND), one could say that every pixel was owned by one and only one HWND. That means that the graphical rendering of a Window’s client area was pretty much limited by the rendering capabilities of an HWND. That does not include things like transformations, animations, occlusion (one pixel being rendered as a combination of two or more overlapping visual elements), etc.
WPF’s vector based rendering system introduces an array of rendering capabilities which HWNDs never even dreamed of. Since pretty much every visual element in WPF is rendered via the vector graphics system (one notable exception being the Popup class), an entire WPF UI can make use of those features out-of-the-box.