Qcard DLL - Lesson 1

Lesson 2
- Alyce Alyce

Qcard DLL - Lesson 1 | About QCard32.DLL | What is in QCard32.DLL? | Getting Started with QCard | DEMO
This is the first in a series of lessons on the use of the QCard32.DLL.

About QCard32.DLL

This series of lessons uses the Qcard32.dll, a freeware library of playing card images.

It is written by Stephen Murphy. His TOS is as follows:

QCard32.DLL is released to the public as FreeWare. It
may be copied and redistributed provided all the
enclosed files remain in tact. The file list is
as follows:

QCARD32.TXT This file
QCARD32.DLL The main DLL file
QCARD32.HLP The documentation file
VB_FILES.ZIP Support for 32-bit VB
C_FILES.ZIP Support for 32-bit C/C++ use
DELPHI.ZIP Support for 32-bit Delphi use

This release is to be used for creating card
applications in 32-bit environments. If you
want to create 16-bit applications, find
the package QCard.zip, which is available
at various sites on the internet and
on Compuserve.

Please read through the QCard32.hlp Help
file for full documentation on how to
use QCard32.dll.

Good luck.

What is in QCard32.DLL?

The DLL includes card face images for all suits and number values, from Ace to King, with hearts, spades, diamonds and clubs. There is a choice of six card backs. There are also jokers. It doesn't just provide images, though. It provides a way to manage the cards.


Getting Started with QCard

The first thing that must be done is to initialize the deck. This is done with a call to InitializeDeck:

    open "qcard32.dll" for dll as #qc
    calldll #qc, "InitializeDeck",_
    hWnd as ulong,_   'window or graphicbox handle
    r as long         'returns 0 on success

The DLL includes two decks of cards. The first deck has indices of 1-52, and the second deck has indices of 53-104. The cards are best displayed with the DealCard function:

    calldll #qc, "DealCard",_
    hWnd as ulong,_   'window or grahicbox handle
    nC as long,_      'index of desired card
    x as long,_       'x location on window
    y as long,_       'y location on window
    r as void

The DLL comes with a very good help file. It says this about DealCard:

  • It updates the card's X and Y properties to the location you deal the card. Most importantly, it grabs from the video display that portion of the screen your card will be covering over. That is, it keeps a copy of the image which lies behind that card.

By default, the cards are displayed face up. The desired status (face up, or face down) is set with the SetCardStatus function, which is as follows:

    calldll #qc, "SetCardStatus",_ 
    nC as long,_    'index of card
    face as long,_  'desired face - 1=front or 0=back
    r as void


The following demo shows the first deck of cards dealt face up in a row. The second deck is dealt face down. Some card sound wavs are included below. You will also need the qcard32.dll.

'i will be our counter var in for/next loops
'start with the basics and open a window containing a graphicbox
    menu #1, "&File", "E&xit", [quit]
    graphicbox #1.g, 0, 0, 700, 440
    open "Card Game" for window_nf as #1
    #1 "trapclose [quit]"
    'get graphicbox handle
    'open the dll
    open "qcard32.dll" for dll as #qc
    'initialize the deck
    Call InitializeDeck hBox
    'draw a nice background
    #1.g "down; fill 10 190 225"
    playwave "shuffle.wav",sync
    'the DLL allows for two decks
    'the first deck includes cards 1 - 52
    'by default, cards are face up
    'deal first deck face up
    for i = 1 to 52
        'window handle, card index number, x, y
        Call DealCard hBox,i,i*12,10
        playwave "card.wav",sync
        'pause 100 milliseconds between cards
        call Pause 100
    playwave "shuffle.wav",sync
    'cards 53 to 104 are in the second deck
    'deal second deck face down
    'set status of all cards to 0, which is face down
    for i = 53 to 104
        call SetCardStatus i, 0
        Call DealCard hBox,i,(i-52)*6,67+i
        playwave "card.wav",sync
        'pause 100 milliseconds between cards
        call Pause 100
[quit] close #qc:close #1:end
'subs and functions:
Sub Pause ms
    'pause ms number of milliseconds
    calldll #kernel32,"Sleep",_
    ms as long, re as void
    End Sub
Sub InitializeDeck hndle
    calldll #qc, "InitializeDeck",_
    hndle as ulong,r as long
    End Sub
Sub DealCard hndle,nC,x,y
    'places card on window whose handle is hndle at x,y
    'nC is number of card - 1-52 in first deck and
    '53-104 in second deck, if used
    calldll #qc, "DealCard",hndle as ulong,nC as long,_
    x as long,y as long,r as void
    End Sub
Sub SetCardStatus nC,face
    'nC is number of card - 1-52 in first deck and
    '53-104 in second deck, if used
    'face:  0=facedown,1=faceup
    calldll #qc, "SetCardStatus",nC as long,_
    face as long,r as void
    End Sub

Qcard DLL - Lesson 1 | About QCard32.DLL | What is in QCard32.DLL? | Getting Started with QCard | DEMO
Lesson 2