My specific question is: How to ignore windows events when in a child form called from that event handler?
Some context: My application captures a fingerprint, and puts up the next form (secondForm) when a print is recognized against the database. I want to ignore any prints they put in while their secondForm is up. The trouble is that when people press the print multiple times, or while their secondForm is up, then the events are queued until after the secondForm closes, so I get multiple calls to the event handler for that person.. I've tried so many ways around this, including calling the routine that open secondForm as a delegate(is that even appropriate), putting a global boolean in the event handler, etc. If I disable fingerprint capture during the oncomplete eventhandler, my form never shows up.
Am I missing something obvious to you here? Much gratitude for any ideas...
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....
' ....
End Class