A Card Deck (#2)

[Home]   [Puzzles & Projects]    [Delphi Techniques]   [Math Topics]   [Library]   [Utilities]

 

Search

 

Search DelphiForFun.org only

Support DFF

 If you shop at Amazon anyway,  consider using this link. We receive a few cents from each purchase.   Thanks.

In Association with Amazon.com

 

Support DFF

 If you benefit from the website,  in terms of knowledge, entertainment value, or something otherwise useful, consider making a donation via PayPal  to help defray the costs.  (No PayPal account necessary to donate via credit card.)  Transaction is secure.

 

 

Contact

Feedback:  Send an e-mail with your comments about this program (or anything else).

 

Search DelphiForFun.org only

 

 

 

 

 

Problem Description

Expand Cards 1 program to add graphic card images.

Background and Techniques

I worked hard this week to try to find a way to use Cards.DLL, the card image dll (dynamic link library) module that comes with windows.  I learned, however, that there are 16 bit (Win 95, 98, ME) and 32 bit versions (Windows NT and 2000) of Cards.DLL  and worse - both versions have the same name.   Accessing 16-bit code from Delphi is non-standard, although I think it can be done.  And Microsoft does not grant permission to distribute either.  I finally decided to use a nice freeware TCard component written by Guilio Ferrari.  (See U_CardComponent header comments for credits.) The card images look very similar to those used in Windows games.   

I renamed the unit to U_CardComponent and moved my TDeck object over there, just to keep the card and deck objects in a common unit.    The resource file containing the card images  (U_CardComponent.res) is 500K bytes long but compresses nicely to about 37K.  As in other freeware components, I have commented out the Register procedure which is required to install the component as a visual component,  we'll just create cards as we need them. 

Since TCard has a property to specify the card back pattern to display, I  added a unit (U_Select) to select the card backs to use for the deck.   It displays all of the available choices and exits when you select one.   

I also added a couple of features to the main unit (U_Cards2).  In addition to the  Shuffle and Deal buttons, you can now drag cards around the screen with the mouse and turn cards over by right clicking.  Not very useful by themselves, but will probably come in handy in implementing games.  Also notice the "wiggle"  in the deck image when you click on the shuffle button.

There are close to 500 lines of code here (although I  must thank Mr. Ferrari for a couple of hundred of them).  According to my size criteria, that puts it in the advanced category - but  there really is nothing too complex going on here - just a lot of details.

Running/Exploring the Program 

bulletDownload source  (Requires DFF Library DFFLibV03 or later to compile)
bulletDownload DFF Library (Current version DFFLibV14_24Mar2014 )
bulletDownload  executable

Suggestions for Further Explorations

Card games, here we come!

 

 

  [Feedback]   [Newsletters (subscribe/view)] [About me]
Copyright 2000-2014, Gary Darby    All rights reserved.