0

我的具体问题是:如何在从该事件处理程序调用的子窗体中忽略 Windows 事件?

一些上下文:我的应用程序捕获一个指纹,并在针对数据库识别打印时提出下一个表单(secondForm)。我想忽略他们在 secondForm 启动时放入的任何打印件。问题是,当人们多次按下打印时,或者当他们的 secondForm 启动时,事件会排队直到 secondForm 关闭之后,所以我会多次调用那个人的事件处理程序。我已经尝试了很多解决这个问题的方法,包括调用作为委托打开 secondForm 的例程(这是否合适),在事件处理程序中放置一个全局布尔值等。如果我在 oncomplete 事件处理程序期间禁用指纹捕获,我的表单将永远不会出现。
我在这里遗漏了一些对你来说很明显的东西吗?非常感谢任何想法......

Imports DPFP.Capture ' DigitalPersona fingerprint reader library
' Simple example to capture a fingerprint from DigitalPersona fingerprint reader.
Public Class SimpleFP
Implements DPFP.Capture.EventHandler

Private mIgnore As Boolean
Public eventHandlerComplete As DPFP.Capture.EventHandler
Public WithEvents mCapture As DPFP.Capture.Capture

Private Sub WaitForFPrint_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Try
        ' set up finger print capture
        mCapture = New DPFP.Capture.Capture
        mCapture.EventHandler = Me
        mCapture.StartCapture()
    Catch ex As Exception
        MsgBox("Problem starting fingerprint reader: " & ex.Message)
    End Try
End Sub

Public Sub FPOnComplete(ByVal Capture As Object, ByVal sernum As String, ByVal sample As DPFP.Sample) _
    Implements DPFP.Capture.EventHandler.OnComplete

    'mCapture.StopCapture()  
    'This is what I want to do, but when I leave this in,  my secondForm won't stay up

    Dim s As String = displaySecondScreen(sample)

    showStatus(s)
    'mCapture.StartCapture()  
     'This is what I want to do, but when I leave this in,  my secondForm won't stay up
End Sub

' Put up second form. This is called from the fingerprint OnComplete event handler.
Private Function displaySecondScreen(ByVal sample As DPFP.Sample) As String

    Dim status As String = "OK"
    Try
        Dim x As DPFP.FeatureSet
        x = extractFeatures(sample)

        ' This is where I match the fp in my code, but I removed here to simplify
        If True Then

            Dim frm As New frmSecondForm
            frm.ShowDialog(Me)
            frm.Dispose()

        Else
            ' No fingerprint match - normal case
            status = "Fingerprint not recognized"
        End If
    Catch ex As Exception
        status = "Exception during fingerprint verification: " & ex.Message
    End Try
    Return status
End Function

' Made rudimentary for this example, but I thought some person new to dpfp  may be able to use this
Private Function extractFeatures(ByVal sample As DPFP.Sample) As DPFP.FeatureSet
    Dim extractor As New DPFP.Processing.FeatureExtraction()
    Dim feedback As New DPFP.Capture.CaptureFeedback()
    Dim features As New DPFP.FeatureSet()
    extractor.CreateFeatureSet(sample, DPFP.Processing.DataPurpose.Verification, feedback, features)
    If feedback = DPFP.Capture.CaptureFeedback.Good Then

    End If
    Return features
End Function

Private Sub debugOut(ByVal s As String)
    Console.WriteLine(s)
End Sub

' Display status on first form
Delegate Sub showStatusCallback(ByVal s As String)

Private Sub showStatus(ByVal s As String)
    If lblStatus.InvokeRequired Then
        Dim d As New showStatusCallback(AddressOf showStatus)
        Me.Invoke(d, New Object() {s})
    Else
        lblStatus.Text = s
    End If
End Sub

' ... followed by other implements dpfp eventhandlers not in use....
' ....

结束类

4

0 回答 0