A Card Deck (#2)

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

 

 

Search

Search WWW

Search DelphiForFun.org

As of October, 2016, Embarcadero is offering a free release of Delphi (Delphi 10.1 Berlin Starter Edition ).     There are a few restrictions, but it is a welcome step toward making more programmers aware of the joys of Delphi.  They do say "Offer may be withdrawn at any time", so don't delay if you want to check it out.  Please use the feedback link to let me know if the link stops working.

 

Support DFF - Shop

 If you shop at Amazon anyway,  consider using this link. 

     

We receive a few cents from each purchase.  Thanks

 


Support DFF - Donate

 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.

Mensa® Daily Puzzlers

For over 15 years Mensa Page-A-Day calendars have provided several puzzles a year for my programming pleasure.  Coding "solvers" is most fun, but many programs also allow user solving, convenient for "fill in the blanks" type.  Below are Amazon  links to the two most recent years.

Mensa® 365 Puzzlers  Calendar 2017

Mensa® 365 Puzzlers Calendar 2018

(Hint: If you can wait, current year calendars are usually on sale in January.)

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 DFFLibV15 )
bulletDownload  executable

Suggestions for Further Explorations

Card games, here we come!

 

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