Solved

using cards.dll

Posted on 1998-09-23
4
141 Views
Last Modified: 2010-04-30
I am a "new" VB programmer. Can anyone out there point me to a tutorial on how to use cards.dll or explain it in simple terms? I was in the process of trying to create a
card game and designing a card shuffling function when some one suggested I simply use the cards.dll already on Windows95. I searched the net and found a bunch of stuff
that confused the heck out of me.
0
Comment
Question by:timothy1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 1

Expert Comment

by:khaledc
ID: 1436303
If you can be more specific it would help.
First, do you know how call a function from Cards.DLL First?
Second, do you know what functions are available in Cards.DLL?
Third, do you have any idea what am I talking about???? :)

I do not think there is a tutorial on Cards.DLL. However, you have to know how to call a function from a DLL in VB. For a start, is that what you want?

Can you tell me what sort of stuff you found on the network.

regards
0
 
LVL 2

Expert Comment

by:WDB
ID: 1436304
0
 
LVL 14

Accepted Solution

by:
waty earned 200 total points
ID: 1436305
Here is a sample code using cards.dll


'****************************************************************
' Name: Card routines
' Description:CARDS.DLL is standard with Microsoft Windows.
'     It is used by
' Solitaire (SOL.EXE), Hearts, etc... as a standard card drawing
' library. You can use it to to create cool card games!
' By: MO
'
' Inputs:None
' Returns:None
' Assumes:None
' Side Effects:None
'
'****************************************************************

'****************************************************************
'Windows API/Global Declarations for :Card routines
'****************************************************************

'     'Delarations and utilities for using CARDS.DLL
'      'Actions for CdtDraw/Ext
'      ' use in the nDraw field
 Global Const C_FACES = 0
 Global Const C_BACKS = 1
 Global Const C_INVERT = 2
'      'Card Numbers
'      ' use in the nCard field
 'from 0 to 51[Ace (club,diamond,heart,spade), Deuce, ... ,
'     King]
'      'Card Backs
'      ' use in the nCard field
 ' CAUTION: when nCard > 53 then nDraw must be = 1 (C_BACKS)
'
 Global Const crosshatch = 53
 Global Const weave1 = 54
 Global Const weave2 = 55
 Global Const robot = 56
 Global Const flowers = 57
 Global Const vine1 = 58
 Global Const vine2 = 59
 Global Const fish1 = 60
 Global Const fish2 = 61
 Global Const shells = 62
 Global Const castle = 63
 Global Const island = 64
 Global Const cardhand = 65
 Global Const UNUSED = 66
 Global Const THE_X = 67
 Global Const THE_O = 68
'      'Initialization
'      ' call before anything else. Returns the default
'      ' width and height for the cards, in pixels.
 Declare Function CdtInit Lib "CARDS.DLL" (nWidth As Integer, nHeight As Integer) As Integer
'      'CdtDraw used to draw a card with the default size
 'at a specified location in a form, picture box or whatever
'     .
 'It can draw any of the 52 faces an 13 different Back desig
'     ns,
 'as well as pile markers such as the X and O. Cards can als
'     o
'      'be drawn in the negative image, eg to show selection.
'      'xOrg = x origin in pixels
'      'yOrg = y origin in pixels
 'nCard = one of the Card Back constants or a card number 0
'     to 51
'      'nDraw = one of the Action constants
'      'nColor = The highlight color
 Declare Function CdtDraw Lib "CARDS.DLL" (ByVal hDC As Integer, ByVal xOrg As Integer, ByVal yOrg As Integer, ByVal nCard As Integer, ByVal nDraw As Integer, ByVal nColor&) As Integer
'      'CdtDrawExt used to draw a card in any size
 'Much the same as CdtDraw, but you can specify the height &
'      width
'      'of the card, as well as location.
'      'nWidth = Width of card in pixels
'      'nHeight = Height of card in pixels.
 Declare Function CdtDrawExt Lib "CARDS.DLL" (ByVal hDC As Integer, ByVal xOrg As Integer, ByVal yOrg As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal nCard As Integer, ByVal nDraw As Integer, ByVal nColor&) As Integer
'      'CdtTerm should be called when the program terminates.
'      ' Primarily it releases memory back to Windows.
 Declare Function CdtTerm Lib "CARDS.DLL" () As Integer
 
'     'general (form level) declarations
Dim nWidth As Integer, nHeight As Integer
Sub Form_Load()
   x% = CdtInit(nWidth, nHeight)
End Sub
Sub Form_Unload(Cancel As Integer)
   ret% = CdtTerm()
End Sub
'     'a command button placed on form1
Sub Cards_Click()
   '      'clubs
   Xleft% = 0
   For i = 0 To 51 Step 4
      ret% = CdtDraw(hDC, Xleft%, 0, i, C_FACES, &HFFFF&)
      Xleft% = Xleft% + nWidth / 4
   Next

   '      'diamonds
   Xleft% = 0
   For i = 1 To 51 Step 4
      ret% = CdtDraw(hDC, Xleft%, nHeight, i, C_FACES, &HFFFF&)
      Xleft% = Xleft% + nWidth / 4
   Next
   '      'hearts
   Xleft% = 0
   For i = 2 To 51 Step 4
      ret% = CdtDraw(hDC, Xleft%, nHeight * 2, i, C_FACES, &HFFFF&)
      Xleft% = Xleft% + nWidth / 4
   Next
   '      'spades
   Xleft% = 0
   For i = 3 To 51 Step 4
      ret% = CdtDraw(hDC, Xleft%, nHeight * 3, i, C_FACES, &HFFFF&)
      Xleft% = Xleft% + nWidth / 4
   Next
   '      'draw card backs
   For i = 53 To 68
      xx% = (i - 53) * nWidth / 3.74
      ret% = CdtDraw(hDC, 4.1 * nWidth, xx%, i, C_BACKS, &HFFFF&)
   Next
End Sub

0
 

Author Comment

by:timothy1
ID: 1436306
It was all familiar to me, but I'll have to study it to figure it all out.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question