Skip to navigation Skip to content
JonRipley.com

Navigation

Main content

CardLib - Use the Microsoft Cards.dll and Cards32.dll

CardLib ( Source | Text | Full )

The CardLib provides an interface to the Windows cards library which is used by all the card games which are supplied with Windows™. CardLib is compatible with the 16-bit and 32-bit versions of Cards.dll and Cards32.dll.

The functions and procedures contained are:

The variables and constants contained are:

See PROCcdtConst in the library source for a full list of constants.

Example Programs

Program Download Description
Bounce Source | Text | Screenshot ) Demonstrates card animation.
Decks Source | Text | Screenshot ) Display all available decks.
Ghosts Source | Text | Screenshot ) Colourful demonstration using ghost cards.
Grid Source | Text | Screenshot ) Display a full deck of cards.
OX Source | Text | Screenshot ) Display the two special decks X and O.
Pairs Source | Text | Screenshot ) The classic card game.
Shrink Source | Text | Screenshot ) Using cdtDrawExt to display cards of different sizes.

PROCcdtInit

Call this procedure to load and initialise Cards32.dll which should be located in the same directory as your program. Call this once at the start of your program using:

PROCcdtInit

PROCcdtDraw(hdc%, x%, y%, card% ,md%, rgb%)

Call this procedure to draw a card on the screen at the coordinates specified in x% and y% (top left corner of the card). The parameter md% controls which drawing mode is used. The following modes are provided:

mdFaceUp
draw face up card (card% in cdAClubs..cdKSpades)
mdFaceDown draw face down card (card% in cdFaceDown1..cdFaceDown12)
mdHilite draw face up card inversely
mdGhost draw a ghost card, card% ignored
mdRemove draw rectangle of background color at x%,y%
mdDeckX draw an X
mdDeckO draw an O

The parameter rgb% specifies the window background colour is only required for mdGhost and mdRemove.

PROCcdtDrawEx(hdc%, x%, y%, rank%, suit%, md%, rgb%)

This procedure is the same as PROCcdtDraw except that you specify the card by rank and suit instead of by card number.

PROCcdtDrawExt(hdc%, x%, y%, dx%, dy%, card%, md%, rgb%)

This procedure is the same as PROCcdtDraw except that you can specify the card width and height in dx% and dy%.

PROCcdtDrawExtEx(hdc%, x%, y%, dx%, dy%, rank%, suit%, md%, rgb%)

This procedure is the same as PROCcdtDrawEx except that you can specify the card width and height in dx% and dy%.

PROCcdtAnimate(hdc%, card%, x%, y%, ispr%)

This procedure draws the animation for the animated cards.

Four cards in the 16 bit library support animation:

Card # Frames Description
cdFaceDown3 4 robot meters
cdFaceDown10 2 bats flapping
cdFaceDown11 4 sun sticks tongue out
cdFaceDown12 4 cards running up and down sleeve

Call PROCcdtAnimate every 250 ms for the proper animation speed with the required frame. The parameter ispr% should contain the sprite to draw (0..1 for cdFaceDown10, 0..3 for others).

PROCcdtTerm

This procedure finalises the cards library and unloads the DLL. Call once at the end of your program.

PROCcdtRedrawArea(x%, y%, dx%, dy%)

This procedure redraws the selected rectangle immediately. Pass the top left corner in x%,y% and size of the area dx%,dy%.

PROCcdtRedrawAll

This procedure redraws the entire window immediately.

PROCcdtRedraw(bool%)

Use this procedure to set the cdtRedraw% flag which controls whether the screen is automatically redrawn after drawing a card.

PROCcdtConst (Internal use)

This procedure, called by PROCcdtInit sets the constants for using the cards library..

FNcdtSuFromCd(card%)

This function returns the suit of a given card.

FNcdtRaFromCd(card%)

This function returns the rank of a given card.

FNcdtCd(rank%, suit%)

This function returns the card number for the rank and suit.

Any Browser! Valid CSS! Valid XHTML 1.0 Transitional