Solved

CARDS32.DLL (IN PICTUREBOX CONTROL)

Posted on 1998-10-29
4
433 Views
Last Modified: 2010-05-18
Dear sir,
  I've tried CARDS32.DLL in VB5 it's fantastic but
  I wonder how can you use this cards in PICTUREBOX

  so if you please , may you tell me
  HOW TO IMPLEMENT IT IN A PICTUREBOX ???

  and finally thanks for your cooperations
0
Comment
Question by:sameh
  • 2
  • 2
4 Comments
 
LVL 13

Accepted Solution

by:
Mirkwood earned 200 total points
ID: 1442293
You can pass the hdc of the picturecontrol to the draw method of cards32. Set the autoredraw property to true.

I can also post the code of a control that I made here if you want to.
0
 
LVL 2

Expert Comment

by:schild
ID: 1442294
Here you can find declerations:


Attribute VB_Name = "Module1"
''*-----------------------------------------------------------------------------
'|    CARDS.BAS
'|
'|    VB Declares for CARDS.DLL file
'|
'|  Copyright(c) 1996 Microsoft Corporation
'-----------------------------------------------------------------------------*'

Public RA As Integer '     '* Rank *'
Public SU As Integer '     '* Suit *'
Public cd As Integer '     '* Card *'

''*-----------------------------------------------------------------------------
'| cdtDraw and cdtDrawExt mode flags
'-----------------------------------------------------------------------------*'
Const mdFaceUp = 0           '* Draw card face up, card to draw specified by cd *'
Const mdFaceDown = 1         '* Draw card face down, back specified by cd (cdFaceDownFirst..cdFaceDownLast) *'
Const mdHilite = 2           '* Same as FaceUp except drawn with NOTSRCCOPY mode *'
Const mdGhost = 3            '* Draw a ghost card -- for ace piles *'
Const mdRemove = 4           '* draw background specified by rgbBgnd *'
Const mdInvisibleGhost = 5   '* ? *'
Const mdDeckX = 6            '* Draw X *'
Const mdDeckO = 7            '* Draw O *'

''*-----------------------------------------------------------------------------
'| Suit and card indices.  Orders of BOTH are important
'-----------------------------------------------------------------------------*'


Const suClub = 0
Const suDiamond = 1
Const suHeart = 2
Const suSpade = 3
Const suMax = 4
Const suFirst = suClub
Const raAce = 0
Const raTwo = 1
Const raThree = 2
Const raFour = 3
Const raFive = 4
Const raSix = 5
Const raSeven = 6
Const raEight = 7
Const raNine = 8
Const raTen = 9
Const raJack = 10
Const raQueen = 11
Const raKing = 12
Const raMax = 13
Const raNil = 15
Const raFirst = raAce

Const cdAClubs = 0
Const cd2Clubs = 4
Const cd3Clubs = 8
Const cd4Clubs = 12
Const cd5Clubs = 16
Const cd6Clubs = 20
Const cd7Clubs = 24
Const cd8Clubs = 28
Const cd9Clubs = 32
Const cdTClubs = 36
Const cdJClubs = 40
Const cdQClubs = 44
Const cdKClubs = 48
Const cdADiamonds = 1
Const cd2Diamonds = 5
Const cd3Diamonds = 9
Const cd4Diamonds = 13
Const cd5Diamonds = 17
Const cd6Diamonds = 21
Const cd7Diamonds = 25
Const cd8Diamonds = 29
Const cd9Diamonds = 33
Const cdTDiamonds = 37
Const cdJDiamonds = 41
Const cdQDiamonds = 45
Const cdKDiamonds = 49
Const cdAHearts = 2
Const cd2Hearts = 6
Const cd3Hearts = 10
Const cd4Hearts = 14
Const cd5Hearts = 18
Const cd6Hearts = 22
Const cd7Hearts = 26
Const cd8Hearts = 30
Const cd9Hearts = 34
Const cdTHearts = 38
Const cdJHearts = 42
Const cdQHearts = 46
Const cdKHearts = 50
Const cdASpades = 3
Const cd2Spades = 7
Const cd3Spades = 11
Const cd4Spades = 15
Const cd5Spades = 19
Const cd6Spades = 23
Const cd7Spades = 27
Const cd8Spades = 31
Const cd9Spades = 35
Const cdTSpades = 39
Const cdJSpades = 43
Const cdQSpades = 47
Const cdKSpades = 51
Const cdFaceDownFirst = 54
Const cdFaceDownLast = 65

'/*-----------------------------------------------------------------------------
'| Face down cds
'-----------------------------------------------------------------------------*/
Const cdFaceDown1 = 54
Const cdFaceDown2 = 55
Const cdFaceDown3 = 56
Const cdFaceDown4 = 57
Const cdFaceDown5 = 58
Const cdFaceDown6 = 59
Const cdFaceDown7 = 60
Const cdFaceDown8 = 61
Const cdFaceDown9 = 62
Const cdFaceDown10 = 63
Const cdFaceDown11 = 64
Const cdFaceDown12 = 65
Const cdFaceDownFirst = cdFaceDown1
Const cdFaceDownLast = cdFaceDown12


'/*-----------------------------------------------------------------------------
'|    cdtInit
'|
'|        Initialize cards.dll -- called once at app boot time.
'|
'|    Arguments:
'|        int FAR *pdxCard: returns card width
'|        int FAR *pdyCard: returns card height
'|
'|    Returns:
'|        TRUE if successful.
'-------------------------------------------------------------------------------*/
'BOOL _declspec(dllexport) cdtInit(int FAR *pdxCard, int FAR *pdyCard);
Declare Function cdtInit Lib "cards.dll" (pdxCard As Integer, pdyCard As Integer) As Integer

'/*-----------------------------------------------------------------------------
'|    cdtDraw
'|
'|        Draw a card
'|
'|    Arguments:
'|        HDC hdc
'|        int x: upper left corner of the card
'|        int y: upper left corner of the card
'|        int cd: card to draw (depends on md)
'|        int md: mode
'|           mdFaceUp:    draw face up card (cd in cdAClubs..cdKSpades)
'|           mdFaceDown:  draw face down card (cd in cdFaceDown1..cdFaceDown12)
'|           mdHilite:    draw face up card inversely
'|           mdGhost:     draw a ghost card, cd ignored
'|           mdRemove:    draw rectangle of background color at x,y
'|           mdDeckX:     draw an X
'|           mdDeckO:     draw an O
'|        DWORD rgbBgnd: table background color (only required for mdGhost and
                                                 mdRemove)
'|
'|    Returns:
'|        TRUE if successful
'-----------------------------------------------------------------------------*/
'BOOL _declspec(dllexport) cdtDraw(HDC hdc, int x, int y, int cd, int md, DWORD rgbBgnd);

Declare Function cdtDraw Lib



0
 
LVL 2

Expert Comment

by:schild
ID: 1442295
nad here some ussage and explanations by "Hard Core Visaul Basic" book:

Private Sub cmdBack_Click()    Dim ordScale As Integer    ordScale = ScaleMode: ScaleMode = vbPixels    SetTimer eatCardBacks    Cls    Dim x As Integer, y As Integer, ecbBack As ECardBack    ecbBack = ecbCrossHatch  ‘ First card back    ‘ Draw cards in 4 by 4 grid    For x = 0 To 3        For y = 0 To 3            cdtDraw Me.hDC, (dxCard * 0.1) + (x * dxCard * 1.1), _                    (dyCard * 0.1) + (y * dyCard * 1.1), _                    ecbBack, ectBacks, QBColor(Random(0, 15))            ecbBack = ecbBack + 1        Next    Next    ScaleMode = ordScaleEnd Sub
The timer loop does essentially the same thing, although its use of static variables makes it look different. Fun ’n Games handles other animation tasks too; AnimateBacks is one of several subs called by the Timer event procedure:

Sub AnimateBacks()    Static x As Integer, y As Integer    Static ecbBack As ECardBack, iState As Integer        ‘ Save scale mode and change to pixels    Dim ordScale As Integer    ordScale = ScaleMode: ScaleMode = vbPixels        ‘ Adjust variables    If ecbBack < ecbCrossHatch Or ecbBack > ecbO Then        ecbBack = ecbCrossHatch        x = 0: y = 0    End If    If x = 4 Then x = 0    If y = 4 Then y = 0: x = x + 1    Select Case ecbBack    Case ecbCrossHatch        ‘ Change color of crosshatch        cdtDraw Me.hDC, (dxCard * 0.1) + (x * dxCard * 1.1), _                (dyCard * 0.1) + (y * dyCard * 1.1), _                ecbBack, ectBacks, QBColor(Random(0, 15))    Case Else ‘ecbRobot, ecbCastle, ecbBeach, ecbCardHand        ‘ Step through animation states        If cdtAnimate(Me.hDC, ecbBack, _                      (dxCard * 0.1) + (x * dxCard * 1.1), _                      (dyCard * 0.1) + (y * dyCard * 1.1), iState) Then            iState = iState + 1            Exit Sub    ‘ Don’t move to next card until final state        End If        iState = 0    ‘ Case Else        ‘ Ignore other cards    End Select    ‘ Move to next card    ecbBack = ecbBack + 1    y = y + 1    ‘ Restore    ScaleMode = ordScaleEnd Sub
Timer loops can be used for a lot more than animation. Think about how to apply them to all your background tasks. Consider doing calculations and file processing while you’re handling user input, for instance. In fact, once you become accustomed to thinking in terms of timer loops, you can end up performing tasks in the background that used to be carried out in the foreground.


Good Luck
Schild
0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1442296
VERSION 5.00
Begin VB.UserControl ctlCard
   BackColor       =   &H00C0C0C0&
   ClientHeight    =   2430
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   1875
   ScaleHeight     =   162
   ScaleMode       =   3  'Pixel
   ScaleWidth      =   125
   ToolboxBitmap   =   "ctlCard.ctx":0000
End
Attribute VB_Name = "ctlCard"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit

'************************************************************
'**************** %2 CardCtrl
'**************** %4 Arjen Bos (arjen.bos@Cyco.nl)
'**************** %7 15-01-1998
'************************************************************

'************************************************************
'**************** PRIVATE DECLARATIONS
'************************************************************

'Function Declarations for CARDS.DLL
Private Declare Function CardInit Lib "CARDS.DLL" Alias "cdtInit" (PointX As Long, PointY As Long) As Long
' Pointers to Card coordinates, returns TRUE if succesful

Private Declare Function DrawCard Lib "CARDS.DLL" Alias "cdtDraw" (ByVal hdc As Long, ByVal PointX As Long, ByVal PointY As Long, ByVal card As Long, ByVal drawmode As Integer, ByVal BkGrnd As Long) As Long
'Parameters:
'hDC-    HDC of window to draw cards on
'x,y -   Upper left hand point
'Card -   Card # (Use CONSTANTS)
'Mode-  Draw Mode for Card, see Constants
'BkGrnd-    An RBG Long value of the Background color for the drawn card
'RETURNS TRUE IF SUCCESSFUL

Private Declare Function DrawCardEX Lib "CARDS.DLL" Alias "cdtDrawExt" (ByVal hdc As Long, ByVal PointX As Long, ByVal PointY As Long, ByVal ExtX As Integer, ByVal ExtY As Integer, ByVal card As Integer, ByVal drawmode As Integer, ByVal BkGrnd As Long) As Integer
' Extended drawing fuction, allows for nonstandard card sizes.
'Same params as above plus:
'ExtX, ExtY-    Lower right hand corner of Card, used to stretch or shrink Cards to specific sizes
'RETURNS TRUE IF SUCCESSFUL

Private Declare Sub EndCard Lib "CARDS.DLL" Alias "cdtTerm" ()
'Call when you are finshed with the DLL.

Private Const SRCCOPY = &HCC0020

Public Enum CardFace
    CF_NONE = -1
   
    CF_CLUBSA = 0
    CF_CLUBS2 = 4
    CF_CLUBS3 = 8
    CF_CLUBS4 = 12
    CF_CLUBS5 = 16
    CF_CLUBS6 = 20
    CF_CLUBS7 = 24
    CF_CLUBS8 = 28
    CF_CLUBS9 = 32
    CF_CLUBS10 = 36
    CF_CLUBSJ = 40
    CF_CLUBSQ = 44
    CF_CLUBSK = 48
   
    CF_DIAMONDSA = 1
    CF_DIAMONDS2 = 5
    CF_DIAMONDS3 = 9
    CF_DIAMONDS4 = 13
    CF_DIAMONDS5 = 17
    CF_DIAMONDS6 = 21
    CF_DIAMONDS7 = 25
    CF_DIAMONDS8 = 29
    CF_DIAMONDS9 = 33
    CF_DIAMONDS10 = 37
    CF_DIAMONDSJ = 41
    CF_DIAMONDSQ = 45
    CF_DIAMONDSK = 49
   
    CF_HEARTSA = 2
    CF_HEARTS2 = 6
    CF_HEARTS3 = 10
    CF_HEARTS4 = 14
    CF_HEARTS5 = 18
    CF_HEARTS6 = 22
    CF_HEARTS7 = 26
    CF_HEARTS8 = 30
    CF_HEARTS9 = 34
    CF_HEARTS10 = 38
    CF_HEARTSJ = 42
    CF_HEARTSQ = 46
    CF_HEARTSK = 50
   
    CF_SPADESA = 3
    CF_SPADES2 = 7
    CF_SPADES3 = 11
    CF_SPADES4 = 15
    CF_SPADES5 = 19
    CF_SPADES6 = 23
    CF_SPADES7 = 27
    CF_SPADES8 = 31
    CF_SPADES9 = 35
    CF_SPADES10 = 39
    CF_SPADESJ = 43
    CF_SPADESQ = 47
    CF_SPADESK = 51
   
    CF_X = 54
    CF_O = 55
End Enum

Enum CardBack
    CB_REDBLUEHATCH = 54
    CB_CROSSHATCH = 55
    CB_ROBOT = 56
    CB_ROSES = 57
    CB_GREENIVY = 58
    CB_BLUEIVY = 59
    CB_REDFISH = 60
    CB_REDFISHBLUEBACK = 61
    CB_SEASHELL = 62
    CB_CASTLE = 63
    CB_PALMTREE = 64
    CB_ACESINHAND = 65
    CB_CUSTOM = 66
End Enum

Public Enum CardDrawMode
    CDW_REGULAR = 0
    CDW_HILITE = 2
    CDW_GHOST = 3
    CDW_REMOVE = 4
    CDW_INVISIBLEGHOST = 5
End Enum

Public Enum CardSideVisible
    CSV_FACEUP = 0
    CSV_FACEDOWN = 1
End Enum

'************************************************************
'**************** PRIVATE VARIABLES
'************************************************************

'The front of the card
Private m_cardface As CardFace

'The back of the card
Private m_cardBack As CardBack

'The drawmode
Private m_cardDrawMode As CardDrawMode

'Card side visible
Private m_cardsidevisible As CardSideVisible

'A custom background
Private m_customPicture As IPictureDisp

Private m_height As Long
Private m_width As Long

'************************************************************
'**************** PUBLIC EVENTS
'************************************************************

Public Event MouseMove(Button As Integer, Shift As Integer)
Public Event MouseUp(Button As Integer, Shift As Integer)
Public Event MouseDown(Button As Integer, Shift As Integer)
Public Event Click()
Public Event DblClick()
Public Event KeyPress(KeyAscii As Integer)

'************************************************************
'**************** PUBLIC ROUTINES
'************************************************************

'CardFace
Public Property Let CardFace(ByVal theCardFace As CardFace)
    m_cardface = theCardFace
    Refresh
End Property

Public Property Get CardFace() As CardFace
    CardFace = m_cardface
End Property

'CardBack
Public Property Let CardBack(ByVal theCardBack As CardBack)
    m_cardBack = theCardBack
    Refresh
End Property

Public Property Get CardBack() As CardBack
    CardBack = m_cardBack
End Property

'CardDrawMode
Public Property Let CardDrawMode(ByVal theCardDrawMode As CardDrawMode)
    If (theCardDrawMode <> CDW_REGULAR And m_cardsidevisible = CSV_FACEDOWN) Then
        Err.Raise -1, "ctlCard", "Only drawmode regular is allowed when card side is facedown"
    End If
    m_cardDrawMode = theCardDrawMode
    Refresh
End Property

Public Property Get CardDrawMode() As CardDrawMode
    CardDrawMode = m_cardDrawMode
End Property


'CardSideVisible
Public Property Let CardSideVisible(ByVal theCardSideVisible As CardSideVisible)
    If (m_cardDrawMode <> CDW_REGULAR And theCardSideVisible = CSV_FACEDOWN) Then
        Err.Raise -1, "ctlCard", "Only drawmode regular is allowed when card side is facedown"
    End If
    m_cardsidevisible = theCardSideVisible
    Refresh
End Property

Public Property Get CardSideVisible() As CardSideVisible
    CardSideVisible = m_cardsidevisible
End Property


Public Property Set CustomPicture(ByVal newValue As IPictureDisp)
    If (Ambient.UserMode = True) Then
        Set m_customPicture = newValue
        Refresh
    Else
        Err.Raise -1, "ctlCard", "Property cannot be modified at design time"
    End If
End Property

Public Property Get CustomPicture() As IPictureDisp
    Set CustomPicture = m_customPicture
End Property


'************************************************************
'**************** PRIVATE EVENT HANDLERS
'************************************************************

Private Sub UserControl_Initialize()
    m_cardface = CF_CLUBS10
    m_cardBack = CB_ACESINHAND
    m_cardDrawMode = CDW_REGULAR
    m_cardsidevisible = CSV_FACEUP
   
    'Call Init to set points
    Call CardInit(m_width, m_height)
End Sub

Private Sub UserControl_KeyPress(KeyAscii As Integer)
    RaiseEvent KeyPress(KeyAscii)
End Sub

Private Sub UserControl_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    RaiseEvent MouseDown(Button, Shift)
End Sub

Private Sub UserControl_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    RaiseEvent MouseMove(Button, Shift)
End Sub

Private Sub UserControl_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    RaiseEvent MouseUp(Button, Shift)
End Sub

Private Sub UserControl_Click()
    RaiseEvent Click
End Sub

Private Sub UserControl_DblClick()
    RaiseEvent DblClick
End Sub


Private Sub UserControl_Paint()
    Dim X As Integer
    Dim card As Long
    Dim drawmode As Long
   
    If (m_cardDrawMode = CDW_REGULAR) Then
        drawmode = m_cardsidevisible
        If (m_cardsidevisible = CSV_FACEDOWN) Then
            card = m_cardBack
        Else
            card = m_cardface
        End If
    Else
        drawmode = m_cardDrawMode
        card = m_cardface ' Only face is supported
    End If
   
    If (card = CB_CUSTOM) Then
        UserControl.PaintPicture m_customPicture, 0, 0, Width, Height, 0, 0, Width, Height, vbSrcCopy
    Else
        'drawCard     DC    centerX    CenterY    Cardface       UP or DOWN     WHITE
        X% = DrawCard(hdc, 0, 0, card, drawmode, RGB(255, 255, 255))
    End If
End Sub

Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
    CardFace = PropBag.ReadProperty("CardFace", m_cardface)
    CardBack = PropBag.ReadProperty("CardBack", m_cardBack)
    CardDrawMode = PropBag.ReadProperty("CardDrawMode", m_cardDrawMode)
    CardSideVisible = PropBag.ReadProperty("CardSideVisible", m_cardsidevisible)
    Refresh
End Sub

Private Sub UserControl_Resize()
    Height = m_height * 15
    Width = m_width * 15
End Sub

Private Sub UserControl_Show()
    Refresh
End Sub

Private Sub UserControl_Terminate()
    'Free Memory :)
    EndCard
End Sub

'Write properties
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
    Call PropBag.WriteProperty("CardFace", m_cardface, CF_CLUBS10)
    Call PropBag.WriteProperty("CardBack", m_cardBack, CB_ACESINHAND)
    Call PropBag.WriteProperty("CardDrawMode", m_cardDrawMode, CDW_REGULAR)
    Call PropBag.WriteProperty("CardSideVisible", m_cardsidevisible, CSV_FACEUP)
End Sub

Public Sub Flip()
    CardSideVisible = IIf(m_cardsidevisible = CSV_FACEUP, CSV_FACEDOWN, CSV_FACEUP)
End Sub

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

746 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

13 Experts available now in Live!

Get 1:1 Help Now