Old School Cards.dll in Today's WPF
I have to wonder just how many applications have used the Cards.DLL over the years. Hundreds? Thousands? It's the Hello World for any card related game...
Calvin Hsia recently blogged about it and using it in a modern WPF app (Modern compared to how he blogged about it in 2004, Displaying playing cards for bridge, written in Visual FoxPro... ;)
Since the DLL is no longer shipped with Windows, he even provides a OneDrive download for it too... :)
I remember each version of Windows had new games. On Windows 3.1 many people played Solitaire. Windows for Workgroups 3.11 introduced Hearts. Somewhere along the way came FreeCell, MineSweeper and Spider Solitaire. This was years before more modern User interfaces, such as WPF existed.
Windows no longer ships Cards.dll which has the images of the cards and some routines that could be called to draw the cards using older techniques, such as Drawing Contexts and GDI.
Using more recent drawing techniques, such as Windows Presentation Foundation (WPF), and more modern languages, such as C# or VB.Net can make programming games easier.
Below is some sample code that extracts bitmaps from a the native Cards.Dll and converts it to a WPF BitmapSource which can be scaled and displayed as an Image in WPF. A timer shuffles the cards. You can click on the form to pause the shuffling.
You can use this code as a basis of a card game. Before writing the code, I was toying with the idea of drawing the cards on a WPF form using WPF Immediate Mode graphics or a combined Immediate and Retained mode graphic system, with HWndHost
Solitaire used a Dll in the Windows\System32 folder called Cards.dll. Because many of you may not have access to a Windows XP machine, I’ve made it available here.