Solved

Anyone know how to use cards.dll?

Posted on 1997-07-22
1
191 Views
Last Modified: 2011-04-14
I would like to make some card games or stuff like that and heard that there is a way to use the cards.dll file to access pre made cards.  If anyone knows how to access them, please share your wisdom :)
0
Comment
Question by:vbquestion
1 Comment
 

Accepted Solution

by:
fury earned 100 total points
ID: 1428734
Declarations and utilities for using CARDS.DLL.

CARDS.DLL is standard with Microsoft Windows. It is used by Solitaire (SOL.EXE), Hearts, etc... as a standard card drawing library.


* FORM1.FRM *

'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


* MODULE1.BAS (global module) *
 '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 designs,
 'as well as pile markers such as the X and O. Cards can also
 '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
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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 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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

911 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now