QCard gives us three symbol cards. We draw them with DrawSymbol. We need the handle of our graphicbox, the index number of the symbol and the x and y location to draw the card. The index to draw an X is 1, the O is 2 and a place holder card is 3.
calldll#qc,"DrawSymbol",_
hndle asulong,_ 'handle of graphicbox
nV aslong,_ '1=X 2=O 3=place holder
nx aslong,_ 'x location
ny aslong,_ 'y location
re asvoid'no return
Disabled Cards
We can set a card's disabled value. We won't allow our users to interact with a disabled card. We do that with SetCardDisabled. We pass the index of the card and the disabled value. 1 is a disabled card and 0 means it is not disabled.
calldll#qc,"SetCardDisabled",_
nC aslong,_ 'card to set
nV aslong,_ '1=disable,0=not disabled
re asvoid'no return
We can later discover if a card is disabled by calling IsCardDisabled. We pass the index of the card to query and a return of 1 tells us the card is disabled. A return of 0 means it is not disabled.
calldll#qc,"IsCardDisabled",_
nC aslong,_ 'card to query
IsCardDisabled aslong'1=disabled
Card Backs
We can also draw a card back image. This is not the same as displaying one of the 104 cards face-down.
'nV can be 1,2,3,4,5,6 for 6 possible designs'draws a cardback image on screencalldll#qc,"DrawBack",_
hndle asulong,_ 'handle of graphicbox
nV aslong,_ 'index of card back, 1-6
x aslong,_ 'x location
y aslong,_ 'y location
r asvoid
DEMO
See Lesson 1 for QCard DLL and WAV files needed for the demo code.
The code for all of the QCard functions for this lesson is demonstrated in the program below.
'An open project card game, begun by Alyce Watson, May 27, 2003.'Uses Qcard32.dll, a freeware library of playing card images.'DLL by Stephen Murphy. Qcard32.DLL website:'http://www.telusplanet.net/public/stevem/nomainwinWindowWidth=640:WindowHeight=480UpperLeftX=1:UpperLeftY=1menu#1,"&File","E&xit",[quit]graphicbox#1.g,0,0,640,440open"Demo"for window_nf as#1#1"trapclose [quit]"'get graphicbox handle
hBox=hwnd(#1.g)'open the dllopen"qcard32.dll"fordllas#qc
'initialize the deckCall InitializeDeck hBox
[new]Call SetDefaultValues
'draw a nice background#1.g "down; fill 10 190 225"#1.g "backcolor 10 190 225"call DrawBack hBox,6,10,10'draw card back design 6 at 10,10call DrawSymbol hBox,1,100,10'draw X at 100,10call DrawSymbol hBox,2,190,10'draw O at 190,10call DrawSymbol hBox,3,280,10'draw placeholder at 280,10call DealCard hBox,33,10,200'draw card at 10,200call DealCard hBox,43,100,200'draw card at 100,200call SetCardDisabled 43,1'set card 43 to disabled status
card1=IsCardDisabled(33)
card2=IsCardDisabled(43)#1.g "place 20 400"#1.g "\Card 1 disabled value is ";card1;" Card 2 disabled value is ";card2
wait[quit]close#qc:close#1:end'''''''''''''''''''''subs and functions:Sub InitializeDeck hndle
calldll#qc,"InitializeDeck",_
hndle asulong,r aslongEndSubSub 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 usedcalldll#qc,"DealCard",hndle asulong,nC aslong,_
x aslong,y aslong,r asvoidEndSubSub DrawBack hndle, nV, x, y
'nV can be 1,2,3,4,5,6 for 6 possible designs'draws a cardback image on screencalldll#qc,"DrawBack",hndle asulong,_
nV aslong,x aslong,y aslong,r asvoidEndSubSub DrawSymbol hndle,nV,nx,ny
calldll#qc,"DrawSymbol",_
hndle asulong,_ 'handle of graphicbox
nV aslong,_ '1=X 2=O 3=place holder
nx aslong,_ 'x location
ny aslong,_ 'y location
re asvoid'no returnendsubfunction IsCardDisabled(nC)calldll#qc,"IsCardDisabled",_
nC aslong,_ 'card to query
IsCardDisabled aslong'1=disabledendfunctionsub SetCardDisabled nC, nV
calldll#qc,"SetCardDisabled",_
nC aslong,_ 'card to set
nV aslong,_ '1=disable,0=not disabled
re asvoid'no returnendsubSub SetDefaultValues
'reset all card properties back to their default values.calldll#qc,"SetDefaultValues",r asvoidEndSub
QCard DLL Lesson 11
Lesson 10 Lesson 12-
QCard DLL Lesson 11 | Drawing Symbol Cards | Disabled Cards | Card Backs | DEMO
See Lesson 1 for QCard DLL and WAV files needed for the demo code.
Drawing Symbol Cards
QCard gives us three symbol cards. We draw them with DrawSymbol. We need the handle of our graphicbox, the index number of the symbol and the x and y location to draw the card. The index to draw an X is 1, the O is 2 and a place holder card is 3.
Disabled Cards
We can set a card's disabled value. We won't allow our users to interact with a disabled card. We do that with SetCardDisabled. We pass the index of the card and the disabled value. 1 is a disabled card and 0 means it is not disabled.
We can later discover if a card is disabled by calling IsCardDisabled. We pass the index of the card to query and a return of 1 tells us the card is disabled. A return of 0 means it is not disabled.
Card Backs
We can also draw a card back image. This is not the same as displaying one of the 104 cards face-down.
DEMO
See Lesson 1 for QCard DLL and WAV files needed for the demo code.The code for all of the QCard functions for this lesson is demonstrated in the program below.
QCard DLL Lesson 11 | Drawing Symbol Cards | Disabled Cards | Card Backs | DEMO
Lesson 10 Lesson 12