frmtest.frm

来自「通用认证码识别(Captchio),非常好的,通用的开发模块」· FRM 代码 · 共 191 行

FRM
191
字号
VERSION 5.00
Begin VB.Form frmTest 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Captchio测试"
   ClientHeight    =   3150
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   6435
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   3150
   ScaleWidth      =   6435
   StartUpPosition =   2  '屏幕中心
   Begin VB.TextBox txtDB 
      Height          =   375
      Left            =   1080
      TabIndex        =   8
      Top             =   120
      Width           =   5215
   End
   Begin VB.CommandButton cmdOpenDB 
      Caption         =   "打开数据"
      Height          =   375
      Left            =   120
      TabIndex        =   7
      Top             =   120
      Width           =   855
   End
   Begin VB.CommandButton cmdQuit 
      Cancel          =   -1  'True
      Caption         =   "退出(&X)"
      Height          =   375
      Left            =   3480
      TabIndex        =   6
      Top             =   2640
      Width           =   1335
   End
   Begin VB.TextBox txtResult 
      Height          =   375
      Left            =   1080
      TabIndex        =   4
      Top             =   2040
      Width           =   5175
   End
   Begin VB.CommandButton cmdRecognize 
      Caption         =   "识别(&R)"
      Default         =   -1  'True
      Height          =   375
      Left            =   1920
      TabIndex        =   3
      Top             =   2640
      Width           =   1335
   End
   Begin VB.CheckBox chkNormalizePic 
      Caption         =   "预处理图片"
      Height          =   375
      Left            =   120
      TabIndex        =   2
      Top             =   2640
      Value           =   1  'Checked
      Width           =   1455
   End
   Begin VB.CommandButton cmdOpenTest 
      Caption         =   "打开图片"
      Height          =   375
      Left            =   120
      TabIndex        =   1
      Top             =   600
      Width           =   855
   End
   Begin VB.PictureBox picItem 
      Appearance      =   0  'Flat
      AutoRedraw      =   -1  'True
      AutoSize        =   -1  'True
      BackColor       =   &H80000005&
      BorderStyle     =   0  'None
      ForeColor       =   &H80000008&
      Height          =   600
      Left            =   1080
      ScaleHeight     =   40
      ScaleMode       =   3  'Pixel
      ScaleWidth      =   348
      TabIndex        =   0
      Top             =   600
      Width           =   5215
   End
   Begin VB.Label lblResult 
      Caption         =   "结果:"
      Height          =   255
      Left            =   120
      TabIndex        =   5
      Top             =   2160
      Width           =   855
   End
End
Attribute VB_Name = "frmTest"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private WithEvents m_ucmCaptcha As Captchio.cCaptcha
Attribute m_ucmCaptcha.VB_VarHelpID = -1


Private Sub cmdOpenDB_Click()
        OpenDB
End Sub

Private Sub OpenDB()
        Dim o_strFileName As String
        With New cDlg
            .flags = cdlOFNFileMustExist Or cdlOFNExplorer
            .Filter = "Captchio识别数据库(*.cdb)|*.cdb"
            .ShowOpen
            o_strFileName = .FileName
        End With
        If o_strFileName <> vbNullString Then
            txtDB.Text = o_strFileName
            m_ucmCaptcha.OpenCharDB o_strFileName
        End If
End Sub

Private Sub cmdOpenTest_Click()
        OpenTestPic
End Sub

Private Sub OpenTestPic()
        Dim o_strFileName As String
        With New cDlg
            .flags = cdlOFNFileMustExist Or cdlOFNExplorer
            .Filter = "图片文件|*.jpg;*.bmp;*.gif;*.wmf;*.png|所有文件(*.*)|*.*"
            .ShowOpen
            o_strFileName = .FileName
        End With
        If o_strFileName <> vbNullString Then
            LoadPic o_strFileName
        End If
End Sub

Private Sub LoadPic(ByVal strFile As String)
        Dim o_lngWidth As Long
        Dim o_lngHeight As Long
        
        m_ucmCaptcha.LoadImage strFile, picItem, o_lngWidth, o_lngHeight
        
        If chkNormalizePic.Value = vbChecked Then
            Dim o_picItem As StdPicture
            Set o_picItem = picItem.Picture
            If o_picItem.Handle <> 0 Then
                m_ucmCaptcha.NormalizePic o_picItem, True, True, True, m_ucmCaptcha.TorrenceCount, m_ucmCaptcha.BorderCount
                Set picItem.Picture = Nothing
                Set picItem.Picture = o_picItem
            End If
            Set o_picItem = Nothing
        End If
        
        txtResult.Text = vbNullString
End Sub

Private Sub cmdQuit_Click()
        Unload Me
End Sub

Private Sub cmdRecognize_Click()
        Recognize
End Sub

Private Sub Recognize()
        txtResult.Text = m_ucmCaptcha.GetStringFromImage(picItem.Picture, chkNormalizePic.Value = vbUnchecked)
End Sub

Private Sub Form_Load()
        Dim o_blnResult As Boolean
        Dim o_strDBPath As String
        
        o_strDBPath = App.Path & "\..\..\..\Samples\Captcha1\Captcha1.cdb"
        
        txtDB.Text = o_strDBPath
        
        Set m_ucmCaptcha = New cCaptcha
        o_blnResult = m_ucmCaptcha.OpenCharDB(o_strDBPath)
        'MsgBox o_blnResult

        LoadPic App.Path & "\..\..\..\Samples\Captcha1\1.bmp"
        
        Recognize
End Sub

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?