Hi guys,
I am writing a card games (pinochle to be specific) that allows the user to play against the computer. Actually, I know how to program the simple IA that it is going to have, or how to keep the score. But, i have (and had always) problems with images. The problem is:
- I do not know how to give an image to a card, how can i program this? Do I need to have all the images in a bmp file? And then?
I dont know how to continue (or begin) cos i dont know even how to put a 1 in a card. I mean, i dont know how to create a card.

Thanks by any answer and i appreciate a lot that you have read this thread. I am sorry for my poor english.

Thank you again
Posted on 2001-10-28 08:54:08 by CodeLover
Hi CodeLover

The way I would do it is to create a few small bmp's and build the card using code. One bmp for each card or one bmp for all cards would take up a lot of space.

Posted on 2001-10-28 09:46:55 by KetilO
This might help. Theres a dll that comes with windows that has the card pictures in the dll so you dont have to create your own. Im sorry i dont know which dll.
Posted on 2001-10-28 10:50:27 by ChimpFace9000
Yes, the DLL is cards.dll, used by microsoft's card games.
Here are an old article about this subject from MIND:
and a tutorial about cards.dll
I hope it helps.
Posted on 2001-10-28 10:59:47 by LuHa
Hi all

Why does'nt this work? :confused:

Posted on 2001-10-28 11:58:45 by KetilO
to much wine,
one way is to create STATIC windows on WM_CREATE
with an image style (API 'CreateWindowEx').
This are the cards !
Load an image via API 'LoadIcon' or via
API 'LoadBitmap'
Images are defined inside resource.
If you wonna load them from a file you can use
API 'LoadImage'. On win2j I think you can also
load metafiles.
Assign an image via API 'SendMessage' STM_SETIMAGE.
You use API 'ShowWindow' to SW_HIDE or SW_SHOWNORMAL the spec. window.
But this is not the best way ...


Posted on 2001-10-28 12:09:17 by Test Department
KetilO, what do you mean it doesn't work? Looks fine to me...
Posted on 2001-10-28 13:16:10 by Qweerdy
Hi Qweerdy

The cards should be 2,3,4 :grin:

Got it working.

Posted on 2001-10-28 13:43:01 by KetilO
That works good for me (I can see 2,3,4,2).

I you want, I can help you for your project.
I started a few months ago, to make a game (I don't remember the name and the aim of this game) but I use a dll (where there are all the cards) and I managed to do randomize the distribution for 2 players.

download it and say if you're interested in it.
Sorry, there is only the exe file. coz I couldn't find the source on my HDD. I will hava a look at it.
Posted on 2001-10-29 05:29:31 by Vom-bonjour:-()
Hi Vom-bonjour:-()

Cards.dll missing. :grin:

Posted on 2001-10-29 05:49:52 by KetilO
Thanks, now it does not look so complicated. I will post my source code in a few days.
Posted on 2001-10-29 05:58:35 by CodeLover
Sorry, I forgot it
Here is the new package with the dll. In fact, I used the Windows DLL (cards.dll) but I extracted all the bmps and I re-made a new dll with only the cards I needed. (because the Windows cards dll is used by many games, so there are cards I don't need).

Can someone say me if it's legal to do that, I mean extract resources from a dll and use these resources ?

If you want, you can go here : www.vombonjour.fr.fm
or at www.chez.com/vombonjour if the first link doesn't work.

It's a chat where you can speak with me if you've got problem.
Posted on 2001-10-29 06:56:00 by Vom-bonjour:-()
Good question Vom-bonjour:-(), i do not know if extracting resources from a DLL is not legal, but: is it legal to use the cards.dll in a commercial game?
Posted on 2001-10-29 14:08:34 by CodeLover
Afternoon, All.

I had a look at the links provided by LuHa.

It seems that it's OK to use cards.dll/cards32.dll in your games, as the author at the MSDN site (Here ) mentions that:

If you write a 32-bit game, you will need to install CARDS32.DLL on the user's machine.

Now, I'm quite sure that MS wouldn't encourage piracy on its own site ;).

Using the info at these sites, I've come up with Win32ASM code for using the card32.dll.

I still wouldn't have a clue how to go about *thunking* to the 16-bit cards.dll. It seems more effort than its worth, unless someone's already come up with the solution.

I've attached the proggy, with associated files.

Have fun. Use it as you please.

Posted on 2001-10-30 05:56:00 by Scronty
Scronty - That's what I was doing yesterday! I like your use of

cdtDraw Proto C :VARARG

I need to investigate that more. I used GetProcAddress to get the 5 functions, and Call to use them..oh well, it worked (hahaha). Thanks for posting that!

I've been unable to find any .asm on shuffling a deck of cards. Anyone have anything?

BTW: Here's what I ended up with:
Posted on 2001-10-30 09:07:28 by gscundiff
Sorry, I'm French,
and I don't understand what you mean with "shuffling a deck of cards" ??

Posted on 2001-10-30 10:01:05 by Vom-bonjour:-()
Hi Vom-bonjour:-()

I was looking at your program (cresus.zip) and noticed that you -shuffled the cards- or -you managed to do randomize the distribution-.

I have seen some C:

For i = 1 to 100 ' or any other large integer
r1 = int(rnd * 52) + 1 'First card
r2 = int(rnd * 52) + 1 ' Second card
tmp = CardArray(r1)
CardArray(r1) = CardArray(r2) ' Swap operation
CardArray(r2) = tmp
Next i

and also read some ideas:

Let's say the we need 10 unique random numbers. We initialize a 10 element array
with 1 through 10 (in order). We then pick a random number from 1 to 10, let's say
we get 3. We swap element 3 with element 10. Then we pick a random number
from 1 to 9; say we get 5. We swap element 5 with element 9. And so on, until we
run out of elements.

I was just wondering what would be the best way to randomize (shuffle) a deck of 52 cards in .asm ??
Posted on 2001-10-30 11:40:03 by gscundiff
I have never made a C prog. so I can't really help you about syntax in C.
But the 2nd idea looks pretty good.
In my prog, I didn't do that, I made two 26 bytes array. (2*26=52 for a 52 cards game).

I use a random number (obtained with GetTickCount function), the number must be between 1 and 52.
Then I put the card number in the 1st array.
then I display the card loaded from the dll resource.
I do the same thing again (after having incremented the pointer to the array), but I check everytime if the card number haven't been already used in the array.

Now the 26 cards (for example for the 1st player) are displayed.

Then I do again for the 2nd array.

So at the end I've got no "same cards", I mean every cards are different.

If you want, I can send you the source code, but I'm sorry that there are no comments, and there must be many French words that are not very important to understand.

Hope this would help a bit.
Posted on 2001-10-30 12:04:28 by Vom-bonjour:-()
Thank you for the explanation. I've read somewhere that someone was trying to do something similar to what you described, but were skeptical that the last few randomizations might take a long time to complete. But it seems to work fine in your program!

Yes, please, I would like to see your source.:)

Posted on 2001-10-30 12:55:03 by gscundiff
1. Get random numbers into an array
2. Copy array of random numbers
3. Sort second array
4. Replace number in first array with index of number in second array
5. Shuffled cards are first array!
Posted on 2001-10-30 18:53:20 by bitRAKE