Bug Vanquisher

22 July 2008

Deep Dive into WPF Graphics-The Lost One

Filed under: WPF — Tanveer Badar @ 9:31 PM

Just a (minor) revival to the forgotten series I was supposed to write.

With service pack 1 for .netfx 3.5, milcore.dll no longer provides the low level rendering primitives for WFP. Instead to preserve compatibility with DWM, all new APIs are provided in wpfgfx.dll, which has some minor inclusions (yet unknown to the world, because WPF team refuses to disclose any information).

This blog post reasons about the decision as:

“The reason is that WPF 3.5 SP1 now uses a new graphics DLL (wpfgfx.dll) and certain changes could not be made to Vista’s existing graphics DLL (milcore.dll) that is also used by DWM.”

Features include things like new Effects framework (H/W accelerated this time, not the weenie S/W rendered loonies), integration with DirectX surfaces [all I can remember right now :)].

Apart from that, all DllImports which used to be like DllImport( “milcore.dll” ) now reference the new wpfgfx.dll.

P.S.: I SO hate this post. I don’t do this sort of news aggregator things! Especially when it is so late.

10 January 2008

Application+WPF=Sexy Experience!

Filed under: WPF — Tanveer Badar @ 11:02 PM

I don’t talk like that, ever. But the application deserves that.


8 December 2007

Yahoo Messenger For Windows Vista

Filed under: Fun, WPF — Tanveer Badar @ 2:45 PM

Or is it just that?

If you have netfx 3.0 (or greater) installed on, you do not need Windows Vista to run it. Here is proof:


The other window is irrelevant apart from the fact that it really is Windows XP. The only thing missing from Yahoo Messenger (for WPF) is that it sticks "For Windows Vista" everywhere while it is entirely capable of running on any system having the required runtime.

18 July 2007

Tim Sneath : Announcing Family.Show 2.0

Filed under: WPF — Tanveer Badar @ 12:17 PM

Tim Sneath : Announcing Family.Show 2.0

Really cool application.

6 June 2007

Get indulged

Filed under: Fun, WPF — Tanveer Badar @ 6:23 PM





Get spacetime3d. Get indulged. The wonders of 3D browsing hit desktops for the first time. I wonder if someone can do a similar thing in WPF, now with the InteractiveVisual3D library?

1 June 2007

An excellent article on dependency properties

Filed under: Tips, WPF — Tanveer Badar @ 5:44 PM

Right from the bowls of WPF SDK team. A superb two article post on dependency properties.

Wha’ happened? Property-changed detection mechanisms in WPF (Part One)

Wha’ Happened Part Two: More Property Changes in WPF

[Edit: A reader rightfully pointed out the mistake I had made thinking these articles were about animations, however, they are about dependency properties and only indirectly about animations because dependency properties can be animated.]

23 April 2007

Deep drive into WPF graphics internals Part 1

Filed under: WPF — Tanveer Badar @ 12:28 PM

[I cannot make up my mind how to best start this post. Instead of delaying it for another month, I opted to post it anyway. <warning>Take it with a pound of salt, I may be terribly wrong in this article.</warning>]

A few pictures from MSDN should be the best start. They show the interaction between Win32 provided API, DirectX and WPF.

  1. How WPF leverages Windows Platform

  2. The Visual tree

  3. How WPF draws your application.

These articles are mainly focused on graphics implementation in PresentationFramework, PresentationCore and WindowsBase. The unmanaged part will discuss milcore.dll, dwm.exe, dwmapi.exe, user32.dll’s redirection APIs.

To dig into all of this, we need a working application. This code will be used through out this post.

using System;
using System.Windows;

namespace WPF
     class App : Window
        public static void Main( )
            ( new Application( ) ).Run( new App( ) );

         protected override void OnRender( System.Windows.Media.DrawingContext drawingContext )
            System.Diagnostics.StackTrace st = new System.Diagnostics.StackTrace( System.Threading.Thread.CurrentThread , true );
             Console.WriteLine( st.ToString( ) );
            base.OnRender( drawingContext );

As the name suggest, OnRender is the only method called to do all the drawing. A debug tip shows that it is really an object of type System.Windows.Media.VisualDrawingContext.

Fire up Reflector and have a look at this class:

As we see VisualDrawingContext does not contain many things. _ownerVisual is any Visual having an associated VisualDrawingContext and CloseCore just calls RenderClose on the contained Visual. DrawingContext is the base class which defines the characteristics of what can be drawn and how. DispatcherObject is of no concern here, but in the going, it is essentially a wrapper around System.Threading.Thread and provides some services which check whether, through VerifyAccess and CheckAccess, the caller is on same thread as UI thread or not.

Furthermore, DrawingContext is abstract, therefore, an instance can never be created. RenderDataDrawingContext has an internal constructor. Same goes for its instance too. A transitive closure with the help of Reflector shows that there is no other way to create an instance publically without going through RenderOpen, which returns an instance of VisualDrawingContext.

You may have noticed by now that I skipped RenderDataDrawingContext’s description. Well that’s the topic for next post.

4 April 2007

Must Read

Filed under: WPF — Tanveer Badar @ 12:00 PM

<warning> Geek stuff. Read this immediately. </warning>

30 March 2007

An interesting presentation

Filed under: WPF — Tanveer Badar @ 12:12 PM

WFP3D team has posted a very interesting presentation on their blog. Have a look!

Create a free website or blog at WordPress.com.