VERSION 5.00
Object = "{E48EFDBF-5838-4A7D-95DD-BC0EC914BD4A}#1.2#0"; "StarCEComponents.ocx"
Begin VB.Form frmCashDrawerKickerSample 
   Caption         =   "StarCEComponents.CashDrawerKicker Sample"
   ClientHeight    =   4185
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   4500
   LinkTopic       =   "Form1"
   ScaleHeight     =   4185
   ScaleWidth      =   4500
   StartUpPosition =   3  'Windows Default
   Begin StarCEComponents.CashDrawerKicker CashDrawerKicker1 
      Height          =   375
      Left            =   3840
      TabIndex        =   17
      Top             =   2280
      Visible         =   0   'False
      Width           =   495
      _ExtentX        =   873
      _ExtentY        =   661
   End
   Begin VB.CommandButton btnIsPrimaryCashDrawerSignalling 
      Caption         =   "IsPrimaryCashDrawerSignalling"
      Height          =   375
      Left            =   120
      TabIndex        =   15
      Top             =   2520
      Width           =   4335
   End
   Begin VB.CommandButton btnOpenDrawer 
      Caption         =   "OpenDrawer"
      Height          =   375
      Left            =   120
      TabIndex        =   14
      Top             =   2040
      Width           =   4335
   End
   Begin VB.Frame Frame2 
      Caption         =   "WaitForPrimaryCashDrawerSignalLevel"
      Height          =   1095
      Left            =   120
      TabIndex        =   10
      Top             =   3000
      Width           =   4335
      Begin VB.OptionButton optSignalLevelLow 
         Caption         =   "Signal Level Low (false)"
         Height          =   255
         Left            =   2160
         TabIndex        =   13
         Top             =   240
         Width           =   2055
      End
      Begin VB.OptionButton optSignalLevelHigh 
         Caption         =   "Signal Level High (true)"
         Height          =   255
         Left            =   120
         TabIndex        =   12
         Top             =   240
         Width           =   2055
      End
      Begin VB.CommandButton btnWaitForPrimaryCashDrawerSignalLevel 
         Caption         =   "WaitForPrimaryCashDrawerSignalLevel"
         Height          =   375
         Left            =   120
         TabIndex        =   11
         Top             =   600
         Width           =   4095
      End
   End
   Begin VB.ComboBox cmbDelayPulseWidth 
      Height          =   315
      ItemData        =   "frmCashDrawerKickerSample.frx":0000
      Left            =   2160
      List            =   "frmCashDrawerKickerSample.frx":0028
      Style           =   2  'Dropdown List
      TabIndex        =   9
      Top             =   1560
      Width           =   975
   End
   Begin VB.ComboBox cmbEnergizePulseWidth 
      Height          =   315
      ItemData        =   "frmCashDrawerKickerSample.frx":006B
      Left            =   2160
      List            =   "frmCashDrawerKickerSample.frx":0093
      Style           =   2  'Dropdown List
      TabIndex        =   8
      Top             =   1200
      Width           =   975
   End
   Begin VB.Frame Frame1 
      Caption         =   "Cash Drawer Selection"
      Height          =   615
      Left            =   120
      TabIndex        =   3
      Top             =   480
      Width           =   4335
      Begin VB.OptionButton optAlternate 
         Caption         =   "Alternate"
         Height          =   255
         Left            =   2160
         TabIndex        =   5
         Top             =   240
         Width           =   1935
      End
      Begin VB.OptionButton optPrimary 
         Caption         =   "Primary"
         Height          =   255
         Left            =   120
         TabIndex        =   4
         Top             =   240
         Width           =   1935
      End
   End
   Begin VB.TextBox txtPrinterQueueName 
      Height          =   285
      Left            =   2160
      TabIndex        =   2
      Top             =   120
      Width           =   2295
   End
   Begin VB.Label Label5 
      Caption         =   "milliseconds"
      Height          =   255
      Left            =   3360
      TabIndex        =   0
      Top             =   1560
      Width           =   1095
   End
   Begin VB.Label Label4 
      Caption         =   "milliseconds"
      Height          =   255
      Left            =   3360
      TabIndex        =   16
      Top             =   1200
      Width           =   1095
   End
   Begin VB.Label Label3 
      Caption         =   "Delay Pulse Width"
      Height          =   255
      Left            =   120
      TabIndex        =   7
      Top             =   1560
      Width           =   1935
   End
   Begin VB.Label Label2 
      Caption         =   "Energize Pulse Width"
      Height          =   255
      Left            =   120
      TabIndex        =   6
      Top             =   1200
      Width           =   1935
   End
   Begin VB.Label Label1 
      Caption         =   "Printer Queue Name"
      Height          =   255
      Left            =   120
      TabIndex        =   1
      Top             =   120
      Width           =   1935
   End
End
Attribute VB_Name = "frmCashDrawerKickerSample"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' Star Micronics Co, Ltd.
' Copyright 2005
'
' This sample illustrates the API usage of the StarCEComponents.CashDrawerKicker control
' in order to control device connected Cash Drawer devices.
'
' Please note the following:
' 1. this project has a Component Reference to the StarCEComponents.ocx library - your's must too
' 2. the CashDrawerKicker control is drawn onto the form but has its Visibility property set to false
'    making it invisible at run-time and suitable for use as the API provider

Private Sub btnIsPrimaryCashDrawerSignalling_Click()

    ' prepare to handle errors coming from CashDrawerKicker
    On Error GoTo HandleError
    
    ' set the printer queue name associated with the printer you're going to control
    CashDrawerKicker1.PrinterQueueName = txtPrinterQueueName
    
    ' read out the IsPrimaryCashDrawerSignalling property with returns the current (i.e. real-time) status of that drawer
    If (CashDrawerKicker1.IsPrimaryCashDrawerSignalling = True) Then
        MsgBox "CashDrawerKicker1.IsPrimaryCashDrawerSignalling = True", vbInformation Or vbOKOnly
    Else
        MsgBox "CashDrawerKicker1.IsPrimaryCashDrawerSignalling = false", vbInformation Or vbOKOnly
    End If

    Exit Sub
    
HandleError:
    ' the CashDrawerKicker control has thrown an error - display and learn from it
    MsgBox "CashDrawerKicker1 threw an exception - err.Number = " & Str(Err.Number) & vbNewLine & "err.Description = " & Err.Description, vbExclamation Or vbOKOnly

End Sub

Private Sub btnOpenDrawer_Click()

    ' prepare to handle errors coming from CashDrawerKicker
    On Error GoTo HandleError
    
    ' set the printer queue name associated with the printer you're going to control
    CashDrawerKicker1.PrinterQueueName = txtPrinterQueueName
    
    If (optPrimary.Value = True) Then
        ' configure the control to manipulate the Primary Cash Drawer
        CashDrawerKicker1.CashDrawerCircuit = PrimaryCircuit
        
        ' set the energize and delay pulse widths
        CashDrawerKicker1.EnergizingPulseWidth = Val(cmbEnergizePulseWidth.Text)
        CashDrawerKicker1.DelayPulseWidth = Val(cmbDelayPulseWidth.Text)
    Else
        ' configure the control to manipulate the Secondary Cash Drawer
        CashDrawerKicker1.CashDrawerCircuit = SecondaryCircuit
    End If
    
    ' open the configured Cash Drawer
    CashDrawerKicker1.OpenCashDrawer
    
    Exit Sub
    
HandleError:
    ' the CashDrawerKicker control has thrown an error - display and learn from it
    MsgBox "CashDrawerKicker1 threw an exception - err.Number = " & Str(Err.Number) & vbNewLine & "err.Description = " & Err.Description, vbExclamation Or vbOKOnly
    
End Sub

Private Sub btnWaitForPrimaryCashDrawerSignalLevel_Click()

    ' prepare to handle errors coming from CashDrawerKicker
    On Error GoTo HandleError
    
    ' set the printer queue name associated with the printer you're going to control
    CashDrawerKicker1.PrinterQueueName = txtPrinterQueueName
    
    If (optSignalLevelHigh = True) Then
        ' have the control poll the Primary Cash Drawer's status until it begins signalling or timeout after 30 seconds (1 second = 1 * 1000 milliseconds)
        CashDrawerKicker1.WaitForPrimaryCashDrawerSignalLevel True, 30 * 1000
    Else
        ' have the control poll the Primary Cash Drawer's status until it stops signalling or timeout after 30 seconds (1 second = 1 * 1000 milliseconds)
        CashDrawerKicker1.WaitForPrimaryCashDrawerSignalLevel False, 30 * 1000
    End If
    
    ' the Primary Cash Drawer attained the specified signal level within the timeout period - success
    MsgBox "The specified signal level has been attained.", vbInformation Or vbOKOnly

    Exit Sub
    
HandleError:
    ' the CashDrawerKicker control has thrown an error - display and learn from it
    ' for this function, the most likely exception will be the timeout exception
    MsgBox "CashDrawerKicker1 threw an exception - err.Number = " & Str(Err.Number) & vbNewLine & "err.Description = " & Err.Description, vbExclamation Or vbOKOnly

End Sub

Private Sub Form_Load()

    ' initialize the user interface elements
    optPrimary = True
    cmbEnergizePulseWidth.ListIndex = 0
    cmbDelayPulseWidth.ListIndex = 0
    optSignalLevelHigh.Value = True

End Sub
