VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form frmMain 
   BorderStyle     =   3  'ũ  ȭ 
   Caption         =   "UCBioBSPCOM_UIDemo for VB"
   ClientHeight    =   6390
   ClientLeft      =   45
   ClientTop       =   345
   ClientWidth     =   12885
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   6390
   ScaleWidth      =   12885
   ShowInTaskbar   =   0   'False
   StartUpPosition =   3  'Windows ⺻
   Begin VB.CheckBox chkCapStyle 
      Caption         =   "Auto Detect"
      Height          =   255
      Index           =   3
      Left            =   960
      TabIndex        =   46
      Top             =   5160
      Width           =   2175
   End
   Begin MSComDlg.CommonDialog CommonDialog 
      Left            =   120
      Top             =   5760
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.CommandButton cmdSetSkin 
      Caption         =   "Set new skin"
      Height          =   375
      Left            =   9600
      TabIndex        =   45
      Top             =   5880
      Width           =   1455
   End
   Begin VB.CommandButton btnClose 
      Caption         =   "Close"
      Height          =   375
      Left            =   11280
      TabIndex        =   44
      Top             =   5880
      Width           =   1455
   End
   Begin VB.Frame Frame8 
      Caption         =   "3) Callback notification"
      Height          =   1335
      Left            =   6480
      TabIndex        =   37
      Top             =   4320
      Width           =   6255
      Begin VB.Frame Frame1 
         Caption         =   "Enroll && Finish Event"
         Height          =   735
         Index           =   1
         Left            =   3000
         TabIndex        =   41
         Top             =   360
         Width           =   3015
         Begin VB.Label LabelEnrollResult 
            Height          =   255
            Left            =   1080
            TabIndex        =   43
            Top             =   360
            Width           =   1695
         End
         Begin VB.Label Label2 
            Caption         =   "Result:"
            Height          =   255
            Left            =   240
            TabIndex        =   42
            Top             =   360
            Width           =   735
         End
      End
      Begin VB.Frame Frame6 
         Caption         =   "Capture Event "
         Height          =   735
         Left            =   240
         TabIndex        =   38
         Top             =   360
         Width           =   2655
         Begin VB.Label LabelImgQuality 
            Height          =   255
            Left            =   1560
            TabIndex        =   40
            Top             =   360
            Width           =   855
         End
         Begin VB.Label Label1 
            Caption         =   "Image Quality:"
            Height          =   255
            Left            =   240
            TabIndex        =   39
            Top             =   360
            Width           =   1335
         End
      End
   End
   Begin VB.Frame Frame5 
      Caption         =   "2) Enrollment"
      Height          =   4095
      Index           =   1
      Left            =   6480
      TabIndex        =   14
      Top             =   120
      Width           =   6255
      Begin VB.CommandButton btnEnroll 
         Caption         =   "Enroll"
         Height          =   375
         Left            =   2400
         TabIndex        =   36
         Top             =   3600
         Width           =   1455
      End
      Begin VB.Frame Frame7 
         Caption         =   "Window style for enrollment"
         Height          =   615
         Left            =   240
         TabIndex        =   33
         Top             =   360
         Width           =   5775
         Begin VB.CheckBox chkRegStyle 
            Caption         =   "No welcome page"
            Height          =   255
            Index           =   0
            Left            =   600
            TabIndex        =   35
            Top             =   240
            Width           =   2055
         End
         Begin VB.CheckBox chkRegStyle 
            Caption         =   "No top most window"
            Height          =   255
            Index           =   1
            Left            =   3000
            TabIndex        =   34
            Top             =   240
            Width           =   2175
         End
      End
      Begin VB.Frame Frame33 
         Caption         =   "User notification message"
         Height          =   1215
         Index           =   0
         Left            =   240
         TabIndex        =   28
         Top             =   2280
         Width           =   5775
         Begin VB.TextBox txtCancelMsg 
            Height          =   285
            Left            =   1560
            TabIndex        =   30
            Top             =   720
            Width           =   3975
         End
         Begin VB.TextBox txtCaptionMsg 
            Height          =   285
            Left            =   1560
            TabIndex        =   29
            Top             =   360
            Width           =   3975
         End
         Begin VB.Label Label 
            Caption         =   "Cancel Msg :"
            Height          =   255
            Index           =   3
            Left            =   240
            TabIndex        =   32
            Top             =   750
            Width           =   1575
         End
         Begin VB.Label Label 
            Caption         =   "Caption Msg :"
            Height          =   255
            Index           =   2
            Left            =   240
            TabIndex        =   31
            Top             =   405
            Width           =   1575
         End
      End
      Begin VB.Frame Frame2 
         Caption         =   "Select finger for enrollment"
         Height          =   1095
         Left            =   240
         TabIndex        =   15
         Top             =   1080
         Width           =   5775
         Begin VB.CheckBox chkFinger 
            Caption         =   "L-Little"
            Height          =   255
            Index           =   9
            Left            =   4680
            TabIndex        =   25
            Top             =   720
            Width           =   975
         End
         Begin VB.CheckBox chkFinger 
            Caption         =   "L-Ring"
            Height          =   255
            Index           =   8
            Left            =   3720
            TabIndex        =   24
            Top             =   720
            Width           =   1215
         End
         Begin VB.CheckBox chkFinger 
            Caption         =   "L-Middle"
            Height          =   255
            Index           =   7
            Left            =   2520
            TabIndex        =   23
            Top             =   720
            Width           =   1215
         End
         Begin VB.CheckBox chkFinger 
            Caption         =   "L-Index"
            Height          =   255
            Index           =   6
            Left            =   1440
            TabIndex        =   22
            Top             =   720
            Width           =   1215
         End
         Begin VB.CheckBox chkFinger 
            Caption         =   "L-Thumb"
            Height          =   255
            Index           =   5
            Left            =   240
            TabIndex        =   21
            Top             =   720
            Width           =   1215
         End
         Begin VB.CheckBox chkFinger 
            Caption         =   "R-Little"
            Height          =   255
            Index           =   4
            Left            =   4680
            TabIndex        =   20
            Top             =   360
            Width           =   975
         End
         Begin VB.CheckBox chkFinger 
            Caption         =   "R-Ring"
            Height          =   255
            Index           =   3
            Left            =   3720
            TabIndex        =   19
            Top             =   360
            Width           =   1215
         End
         Begin VB.CheckBox chkFinger 
            Caption         =   "R-Middle"
            Height          =   255
            Index           =   2
            Left            =   2520
            TabIndex        =   18
            Top             =   360
            Width           =   1215
         End
         Begin VB.CheckBox chkFinger 
            Caption         =   "R-Index"
            Height          =   255
            Index           =   1
            Left            =   1440
            TabIndex        =   17
            Top             =   360
            Width           =   1215
         End
         Begin VB.CheckBox chkFinger 
            Caption         =   "R-Thumb"
            Height          =   255
            Index           =   0
            Left            =   240
            TabIndex        =   16
            Top             =   360
            Width           =   1215
         End
      End
   End
   Begin VB.Frame Frame3 
      Caption         =   "1) Capture"
      Height          =   5535
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   6135
      Begin VB.CommandButton btnCapture 
         Caption         =   "Capture"
         Height          =   375
         Left            =   3600
         TabIndex        =   27
         Top             =   5040
         Width           =   1455
      End
      Begin VB.OptionButton optWinStyle 
         Caption         =   "Invisible type"
         Height          =   255
         Index           =   1
         Left            =   240
         TabIndex        =   26
         Top             =   1560
         Width           =   2895
      End
      Begin VB.Frame Frame 
         Caption         =   "Window style for popup"
         Height          =   615
         Index           =   2
         Left            =   480
         TabIndex        =   11
         Top             =   720
         Width           =   5415
         Begin VB.CheckBox chkCapStyle 
            Caption         =   "No top most window"
            Height          =   255
            Index           =   1
            Left            =   2760
            TabIndex        =   13
            Top             =   240
            Width           =   2175
         End
         Begin VB.CheckBox chkCapStyle 
            Caption         =   "No fingerprint image"
            Height          =   255
            Index           =   0
            Left            =   360
            TabIndex        =   12
            Top             =   240
            Width           =   2175
         End
      End
      Begin VB.OptionButton optWinStyle 
         Caption         =   "Popup type"
         Height          =   255
         Index           =   0
         Left            =   240
         TabIndex        =   10
         Top             =   360
         Value           =   -1  'True
         Width           =   2775
      End
      Begin VB.Frame Frame 
         Caption         =   "Window style for invisible"
         Height          =   2895
         Index           =   3
         Left            =   480
         TabIndex        =   1
         Top             =   1920
         Width           =   5415
         Begin VB.PictureBox pic 
            BackColor       =   &H00FFFFFF&
            Height          =   1935
            Left            =   720
            ScaleHeight     =   1875
            ScaleWidth      =   1755
            TabIndex        =   9
            Top             =   720
            Width           =   1815
         End
         Begin VB.Frame Frame 
            Caption         =   "Bk Color"
            Height          =   735
            Index           =   1
            Left            =   2880
            TabIndex        =   6
            Top             =   1680
            Width           =   2295
            Begin VB.TextBox txtBkColor 
               Height          =   285
               Left            =   720
               TabIndex        =   7
               Top             =   300
               Width           =   1455
            End
            Begin VB.Label LabelRGB 
               Caption         =   "RGB :"
               Height          =   255
               Index           =   1
               Left            =   120
               TabIndex        =   8
               Top             =   360
               Width           =   615
            End
         End
         Begin VB.Frame Frame 
            Caption         =   "Fp Color"
            Height          =   735
            Index           =   0
            Left            =   2880
            TabIndex        =   3
            Top             =   840
            Width           =   2295
            Begin VB.TextBox txtFpColor 
               Height          =   285
               Left            =   720
               TabIndex        =   4
               Top             =   300
               Width           =   1455
            End
            Begin VB.Label LabelRGB 
               Caption         =   "RGB :"
               Height          =   255
               Index           =   0
               Left            =   120
               TabIndex        =   5
               Top             =   360
               Width           =   615
            End
         End
         Begin VB.CheckBox chkCapStyle 
            Caption         =   "Use external Fp window"
            Height          =   255
            Index           =   2
            Left            =   360
            TabIndex        =   2
            Top             =   360
            Width           =   3135
         End
      End
   End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' Declaration global variables
Dim WithEvents objUCBioBSP As UCBioBSPCOMLib.UCBioBSP
Attribute objUCBioBSP.VB_VarHelpID = -1

Dim objDevice As IDevice                ' Device object
Dim objExtraction As IExtraction        ' Extraction object
Dim objMatching As IMatching            ' Matching object
Sub SetInitValue(bIsCapture As Boolean)

    ' Window style
    If optWinStyle(0).Value Then
        objUCBioBSP.WindowStyle = 0
    ElseIf optWinStyle(1).Value Then
        objUCBioBSP.WindowStyle = 1
        
        objUCBioBSP.FPForeColor = txtFpColor.Text
        objUCBioBSP.FPBackColor = txtBkColor.Text
        
        If chkCapStyle(2).Value = 1 Then
            objUCBioBSP.FingerWnd = pic.hWnd
        Else
            objUCBioBSP.FingerWnd = 0
        End If

    End If

    ' Window Option
    If chkCapStyle(0).Value = 1 Then
        objUCBioBSP.WindowOption(&H10000) = True
    Else
        objUCBioBSP.WindowOption(&H10000) = False
    End If
    
    If bIsCapture Then
        If chkCapStyle(1).Value = 1 Then
            objUCBioBSP.WindowOption(&H40000) = True
        Else
            objUCBioBSP.WindowOption(&H40000) = False
        End If
    Else
        If chkRegStyle(1).Value = 1 Then
            objUCBioBSP.WindowOption(&H40000) = True
        Else
            objUCBioBSP.WindowOption(&H40000) = False
        End If
    End If
    
    If chkRegStyle(0).Value = 1 Then
        objUCBioBSP.WindowOption(&H20000) = True
    Else
        objUCBioBSP.WindowOption(&H20000) = False
    End If
    
    ' Select finger for enrollment
    For i = 0 To 9
        If chkFinger(i).Value <> 1 Then
            objUCBioBSP.DisableFingerForEnroll(i + 1) = True
        Else
            objUCBioBSP.DisableFingerForEnroll(i + 1) = False
        End If
        
    Next i

    ' Message
    objUCBioBSP.CaptionMsg = txtCaptionMsg.Text
    objUCBioBSP.CancelMsg = txtCancelMsg.Text
End Sub

Private Sub btnCapture_Click()
    Call SetInitValue(True)
    
    Call objDevice.Open(&HFF)   ' 0xFF - Auto
    
    If chkCapStyle(3).Value = 1 Then
        Call objDevice.SetAutoDetect(1)
    Else
        Call objDevice.SetAutoDetect(0)
    End If
    
    Call objExtraction.Capture
    Call objDevice.Close(&HFF)
End Sub

Private Sub btnClose_Click()
    End
End Sub

Private Sub btnEnroll_Click()
    Call SetInitValue(False)
    
    Call objDevice.Open(&HFF)   ' 0xFF - Auto
    Call objExtraction.Enroll(Null)
    Call objDevice.Close(&HFF)
End Sub

Private Sub cmdSetSkin_Click()
    Dim szSkinFileName As String
    
    CommonDialog.Filter = "DLL Files (*.dll)"
    CommonDialog.Flags = cdlOFNHideReadOnly
    
    CommonDialog.ShowOpen
    
    If CommonDialog.CancelError = False Then
    
        szSkinFileName = CommonDialog.FileName
        
        If szSkinFileName <> "" Then
            ' Set skin resource
            Call objUCBioBSP.SetSkinResource(szSkinFileName)
            
            If objUCBioBSP.ErrorCode = 0 Then
                MsgBox "Succeeded to set new skin to BSP"
            Else
                MsgBox objUCBioBSP.ErrorDescription & " [" & objUCBioBSP.ErrorCode & "]", vbOKOnly
            End If
        End If
    End If
End Sub

Private Sub Form_Load()
    ' Create UCBioBSP object
    Set objUCBioBSP = New UCBioBSPCOMLib.UCBioBSP
    Set objDevice = objUCBioBSP.Device
    Set objExtraction = objUCBioBSP.Extraction
    Set objMatching = objUCBioBSP.Matching
    
    ' Check initialize object
    If objUCBioBSP.ErrorCode = 0 Then
        ' Get UCBioBSP version
        frmMain.Caption = "UCBioBSPCOM_UIDemo for VB - Version : " & objUCBioBSP.MajorVersion & "." & objUCBioBSP.MinorVersion
    Else
        MsgBox objUCBioBSP.ErrorDescription & " [" & objUCBioBSP.ErrorCode & "]", vbOKOnly
    End If
    
    
    For i = 0 To 9
        chkFinger(i).Value = 1
    Next i
    
    chkCapStyle(2).Value = 1
    
    txtFpColor.Text = "000000"
    txtBkColor.Text = "FFFFFF"
    
    Call optWinStyle_Click(0)
End Sub

Private Sub objUCBioBSP_OnCaptureEvent(ByVal Quality As Long)
    frmMain.LabelImgQuality.Caption = Str$(Quality)
End Sub

Private Sub objUCBioBSP_OnEnrollEvent(ByVal EventID As Long)
    Dim strEventMsg As String
    
    If EventID = 0 Then
        strEventMsg = "OK"
    ElseIf EventID = 769 Then
        strEventMsg = "Cancel"
    ElseIf EventID = 770 Then
        strEventMsg = "Back"
    ElseIf EventID = 771 Then
        strEventMsg = "Timeout"
    ElseIf EventID = 772 Then
        strEventMsg = "Fake"
    ElseIf EventID = 773 Then
        strEventMsg = "Place finger"
    ElseIf EventID = 774 Then
        strEventMsg = "Hold finger"
    ElseIf EventID = 775 Then
        strEventMsg = "Remove finger"
    ElseIf EventID = 776 Then
        strEventMsg = "Place again"
    ElseIf EventID = 777 Then
        strEventMsg = "Processing"
    ElseIf EventID = 778 Then
        strEventMsg = "Match Failed"
    End If
    
    frmMain.LabelEnrollResult.Caption = strEventMsg & " (" & Str$(EventID) & ")"
End Sub

Private Sub optWinStyle_Click(Index As Integer)
    If Index = 0 Then
        chkCapStyle(0).Enabled = True
        chkCapStyle(1).Enabled = True
        Frame(2).Enabled = True
        
        chkCapStyle(2).Enabled = False
        txtFpColor.Enabled = False
        txtBkColor.Enabled = False
        Frame(0).Enabled = False
        Frame(1).Enabled = False
        Frame(3).Enabled = False
        LabelRGB(0).Enabled = False
        LabelRGB(1).Enabled = False
    Else
        chkCapStyle(0).Enabled = False
        chkCapStyle(1).Enabled = False
        Frame(2).Enabled = False
            
        chkCapStyle(2).Enabled = True
        txtFpColor.Enabled = True
        txtBkColor.Enabled = True
        Frame(0).Enabled = True
        Frame(1).Enabled = True
        Frame(3).Enabled = True
        LabelRGB(0).Enabled = True
        LabelRGB(1).Enabled = True
    End If
End Sub
