home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form frmMain
- Caption = "MicroHelp MhCard Example"
- ClientHeight = 6150
- ClientLeft = 1980
- ClientTop = 1695
- ClientWidth = 8040
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- ForeColor = &H80000008&
- Height = 6585
- Left = 1920
- LinkTopic = "Form1"
- ScaleHeight = 6150
- ScaleWidth = 8040
- Top = 1320
- Width = 8160
- Begin VB.CommandButton cmdReshuffle
- Appearance = 0 'Flat
- BackColor = &H80000005&
- Caption = "cmdReshuffle"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 375
- Left = 225
- TabIndex = 5
- Top = 4545
- Width = 1275
- End
- Begin VB.Frame frmCard
- Caption = "frmCard"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 1950
- Left = 132
- TabIndex = 1
- Top = 108
- Width = 3300
- Begin VB.ComboBox cboBack
- Appearance = 0 'Flat
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 315
- Left = 1440
- Style = 2 'Dropdown List
- TabIndex = 4
- Top = 1485
- Width = 1635
- End
- Begin VB.ComboBox cboValue
- Appearance = 0 'Flat
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 315
- Left = 1440
- Style = 2 'Dropdown List
- TabIndex = 3
- Top = 1125
- Width = 1635
- End
- Begin VB.ComboBox cboSuit
- Appearance = 0 'Flat
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 315
- Left = 1440
- Style = 2 'Dropdown List
- TabIndex = 2
- Top = 765
- Width = 1635
- End
- Begin VB.Label lblSettings
- Appearance = 0 'Flat
- BackColor = &H80000005&
- BackStyle = 0 'Transparent
- Caption = "lblSettings"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = -1 'True
- strikethrough = 0 'False
- EndProperty
- ForeColor = &H80000008&
- Height = 420
- Left = 180
- TabIndex = 12
- Top = 270
- Width = 2895
- End
- Begin VB.Label lblCard
- Appearance = 0 'Flat
- BackColor = &H80000005&
- BackStyle = 0 'Transparent
- Caption = "lblCard"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- ForeColor = &H80000008&
- Height = 240
- Index = 2
- Left = 180
- TabIndex = 7
- Top = 1530
- Width = 1185
- End
- Begin VB.Label lblCard
- Appearance = 0 'Flat
- BackColor = &H80000005&
- BackStyle = 0 'Transparent
- Caption = "lblCard"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- ForeColor = &H80000008&
- Height = 240
- Index = 1
- Left = 180
- TabIndex = 8
- Top = 1170
- Width = 1185
- End
- Begin VB.Label lblCard
- Appearance = 0 'Flat
- BackColor = &H80000005&
- BackStyle = 0 'Transparent
- Caption = "lblCard"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- ForeColor = &H80000008&
- Height = 240
- Index = 0
- Left = 180
- TabIndex = 6
- Top = 810
- Width = 1185
- End
- End
- Begin VB.CommandButton cmdDeal
- Appearance = 0 'Flat
- BackColor = &H80000005&
- Caption = "cmdDeal"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 375
- Left = 225
- TabIndex = 0
- Top = 4140
- Width = 1275
- End
- Begin Mhcd200Lib.MhCardDeck MhCardDeck1
- Height = 1425
- Index = 0
- Left = 315
- TabIndex = 14
- Top = 2655
- Width = 1065
- _Version = 65536
- _ExtentX = 1879
- _ExtentY = 2514
- _StockProps = 65
- BackColor = 12632256
- TintColor = 16711935
- Autosize = -1 'True
- Suit = 3
- CustomBack = "mhcd20_a.frx":0000
- End
- Begin VB.Label lblDeal
- Alignment = 2 'Center
- Appearance = 0 'Flat
- BackColor = &H80000005&
- BackStyle = 0 'Transparent
- Caption = "lblDeal"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = -1 'True
- strikethrough = 0 'False
- EndProperty
- ForeColor = &H80000008&
- Height = 960
- Left = 90
- TabIndex = 13
- Top = 4950
- Width = 1545
- End
- Begin VB.Label lblTable
- Alignment = 1 'Right Justify
- Appearance = 0 'Flat
- BackColor = &H80000005&
- Caption = "lblTable"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = -1 'True
- strikethrough = 0 'False
- EndProperty
- ForeColor = &H80000008&
- Height = 1095
- Left = 3825
- TabIndex = 11
- Top = 2970
- Width = 1950
- End
- Begin VB.Label lblDescription
- Alignment = 2 'Center
- Appearance = 0 'Flat
- BackColor = &H80000005&
- BackStyle = 0 'Transparent
- Caption = "lblDescription"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- ForeColor = &H80000008&
- Height = 1455
- Left = 3690
- TabIndex = 10
- Top = 225
- Width = 2445
- End
- Begin VB.Label lblCardTable
- Alignment = 2 'Center
- Appearance = 0 'Flat
- BackColor = &H80000005&
- BackStyle = 0 'Transparent
- Caption = "lblCardTable"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 12
- underline = 0 'False
- italic = -1 'True
- strikethrough = 0 'False
- EndProperty
- ForeColor = &H80000008&
- Height = 330
- Left = 0
- TabIndex = 9
- Top = 2205
- Width = 6270
- End
- Begin VB.Shape shpDeckUp
- FillColor = &H00FFFFFF&
- FillStyle = 0 'Solid
- Height = 2805
- Left = 1710
- Top = 2835
- Width = 4200
- End
- Begin VB.Shape shpTable
- FillColor = &H00008000&
- FillStyle = 0 'Solid
- Height = 3435
- Left = 0
- Top = 2565
- Width = 6270
- End
- Attribute VB_Name = "frmMain"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- Option Explicit
- Const iInch = 1440
- Dim sSuit(0 To 3) As String
- Dim sValue(0 To 13) As String
- Dim sBack(0 To 12) As String
- Dim iCardCount As Integer
- Dim iDragging As Integer
- Private Sub cboBack_Change()
- MhCardDeck1(0).CardBack = cboBack.ListIndex
- End Sub
- Private Sub cboBack_Click()
- cboBack_Change
- End Sub
- Private Sub cmdDeal_Click()
- Dim iSuit As Integer
- Dim iValue As Integer
- Dim iLeft As Integer
- Dim iTop As Integer
- Dim iTest1 As Integer
- Dim iTest2 As Integer
- Dim iTest3 As Integer
- Dim iTest4 As Integer
- ' Don't deal if no more cards will fit on screen
- ' (first card will always show).
- iTest1 = MhCardDeck1(iCardCount).Left + MhCardDeck1(iCardCount).Width
- iTest2 = shpDeckUp.Left + shpDeckUp.Width
- iTest3 = MhCardDeck1(iCardCount).Top + MhCardDeck1(iCardCount).Height
- iTest4 = shpDeckUp.Top + shpDeckUp.Height
- If (iTest1 > iTest2 - (0.25 * iInch)) Or (iTest3 > iTest4 - (0.25 * iInch)) Then Exit Sub
- ' Get settings of the card to be dealt from the combo boxes.
- iSuit = cboSuit.ListIndex
- iValue = cboValue.ListIndex
- ' Create new instance of the card and configure it
- ' with the selected values.
- iCardCount = iCardCount + 1
- Load MhCardDeck1(iCardCount)
- MhCardDeck1(iCardCount).Visible = False
- MhCardDeck1(iCardCount).Suit = iSuit
- MhCardDeck1(iCardCount).Value = iValue
- MhCardDeck1(iCardCount).CardBack = MhCardDeck1(0).CardBack
- ' Reposition card to white area and shift it to the right
- ' of the card underneath.
- iLeft = shpDeckUp.Left + (0.25 * iInch) + iCardCount * (0.1 * iInch)
- iTop = shpDeckUp.Top + (0.25 * iInch) + iCardCount * (0.1 * iInch)
- MhCardDeck1(iCardCount).Move iLeft, iTop
- ' Display.
- MhCardDeck1(iCardCount).Visible = True
- ' Now cycle through card types.
- If cboSuit.ListIndex < cboSuit.ListCount - 1 Then
- cboSuit.ListIndex = cboSuit.ListIndex + 1
- Else
- cboSuit.ListIndex = 0
- End If
- If cboValue.ListIndex < cboValue.ListCount - 1 Then
- cboValue.ListIndex = cboValue.ListIndex + 1
- Else
- cboValue.ListIndex = 0
- End If
- If cboBack.ListIndex < cboBack.ListCount - 1 Then
- cboBack.ListIndex = cboBack.ListIndex + 1
- Else
- cboBack.ListIndex = 0
- End If
- MhCardDeck1(iCardCount).ZOrder
- End Sub
- Private Sub cmdReshuffle_Click()
- Dim iCount As Integer
- ' Unload all card controls that were loaded
- ' and reset the card count to zero.
- For iCount = 1 To iCardCount
- Unload MhCardDeck1(iCount)
- Next
- iCardCount = 0
- End Sub
- Private Sub Form_Load()
- LoadCaptions
- ' Load the names of the card settings into their
- ' string arrays so that they can be easily set.
- Set_Defaults
- iCardCount = 0
- ' Set default type of card that will be displayed on
- ' the first deal (two of clubs with a red check back).
- cboSuit.ListIndex = 0
- cboValue.ListIndex = 2
- cboBack.ListIndex = 0
- ' center form to screen
- Move Abs(Screen.Width - Width) \ 2, Abs(Screen.Height - Height) \ 2
- End Sub
- Private Sub Form_Resize()
- ' Don't get too small.
- If Me.ScaleWidth < 5025 Then Exit Sub
- If Me.ScaleHeight < 5025 Then Exit Sub
- ' Resize shapes.
- shpTable.Width = frmMain.ScaleWidth
- shpTable.Height = frmMain.ScaleHeight - shpTable.Top
- shpDeckUp.Top = shpTable.Top + (0.25 * iInch)
- shpDeckUp.Width = shpTable.Width - shpDeckUp.Left - (0.25 * iInch)
- shpDeckUp.Height = shpTable.Height - (0.5 * iInch)
- ' Resize labels.
- lblCardTable.Width = frmMain.ScaleWidth
- lblTable.Left = shpDeckUp.Left + shpDeckUp.Width - lblTable.Width - (0.1 * iInch)
- End Sub
- ' KEY: caption text
- ' PURPOSE: Load default text into controls.
- ' PARAMETERS: {none}
- ' RETURNS: {nothing}
- Private Sub LoadCaptions()
- Dim sCaption As String
- frmCard.Caption = "Card Settings"
- lblCard(0).Caption = "&Suit:"
- lblCard(1).Caption = "&Value:"
- lblCard(2).Caption = "&Back Image:"
- lblCardTable.Caption = "Dealers-R-Us"
- cmdDeal.Caption = "&Deal"
- cmdReshuffle.Caption = "&Reshuffle"
- sCaption = "The MhCard control gives you a quick way to start "
- sCaption = sCaption & "your game application. Specify the Card "
- sCaption = sCaption & "Settings you want and press Deal to have that "
- sCaption = sCaption & "card dealt."
- lblDescription.Caption = sCaption
- sCaption = "The top card dealt can be dragged back to the deck "
- sCaption = sCaption & "or right-clicked to be flipped over."
- lblTable.Caption = sCaption
- sCaption = "Specify the suit, value, and card back for the next "
- sCaption = sCaption & "card to be dealt."
- lblSettings.Caption = sCaption
- sCaption = "Press Deal to deal a new card to the table. Press "
- sCaption = sCaption & "Reshuffle to get rid of all dealt cards."
- lblDeal.Caption = sCaption
- End Sub
- Private Sub MhCardDeck1_DragDrop(Index As Integer, Source As Control, X As Single, Y As Single)
- ' Stop dragging card and drop it;
- ' this puts it back on the deck.
- If iDragging And Index = 0 Then
- MhCardDeck1(iCardCount).Drag 2
- Unload MhCardDeck1(iCardCount)
- iCardCount = iCardCount - 1
- End If
- End Sub
- Private Sub MhCardDeck1_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
- ' Begin draggin card (if it is the last card dealt).
- If Button = 1 And Index = iCardCount And Index <> 0 Then
- MhCardDeck1(Index).Drag 1
- iDragging = True
- ' Flip card over if this is a right click.
- ElseIf Button = 2 And Index > 0 Then
- ' Show back.
- If MhCardDeck1(Index).Value <> 0 Then
- MhCardDeck1(Index).Value = 0
- ' Show front.
- Else
- MhCardDeck1(Index).Value = cboValue.ListIndex
- End If
- End If
- End Sub
- ' KEY: default suit value back card
- ' PURPOSE: Fill arrays for card settings and
- ' load values into combo boxes.
- ' PARAMETERS: {none}
- ' RETURNS: {nothing}
- Private Sub Set_Defaults()
- Dim iCount As Integer
- ' Name of the suits.
- sSuit(0) = "Clubs"
- sSuit(1) = "Diamonds"
- sSuit(2) = "Hearts"
- sSuit(3) = "Spades"
- For iCount = 0 To UBound(sSuit)
- cboSuit.AddItem sSuit(iCount)
- Next
- ' Value of the card (major or minor).
- sValue(0) = "Back"
- sValue(1) = "Ace"
- For iCount = 2 To 10
- sValue(iCount) = Format$(iCount)
- Next
- sValue(11) = "Jack"
- sValue(12) = "Queen"
- sValue(13) = "King"
- For iCount = 0 To UBound(sValue)
- cboValue.AddItem sValue(iCount)
- Next
- ' Name of the image displayed on the back of cards.
- sBack(0) = "Red Checks"
- sBack(1) = "Blue Checks"
- sBack(2) = "Red Hatch"
- sBack(3) = "Blue Hatch"
- sBack(4) = "Robot"
- sBack(5) = "Roses"
- sBack(6) = "Leaves 1"
- sBack(7) = "Leaves 2"
- sBack(8) = "Fish"
- sBack(9) = "Conch"
- sBack(10) = "Castle"
- sBack(11) = "Beach"
- sBack(12) = "Hand"
- For iCount = 0 To UBound(sBack)
- cboBack.AddItem sBack(iCount)
- Next
- End Sub
-