From: Olexandr Kravets Olexandr on
I am writing application for Symbol MC70 unit. For implementation of scanning
functionality I am using SMDK for .NET.
I have application, which performs scan on first form and from the handler
it will opens next form. From this form after successful scan, I am trying to
show next form. Unfortunately, it doesn't work.
Example from Symbol CS_ScanSample3 is not really good, because it will opens
next form not from handler.

Did anybody implemented such functionality?

Thanks in advance!
Olexandr.
From: savvaschr on
Try This
Copy and Paste the following


Private Function InitReader() As Boolean

' If reader is already present then fail initialize
If Not (Me.MyReader Is Nothing) Then

Return False

End If

'Create new reader, first available reader will be used.
Me.MyReader = New Symbol.Barcode.Reader

'Create reader data
Me.MyReaderData = New Symbol.Barcode.ReaderData( _

Symbol.Barcode.ReaderDataTypes.Text, _

Symbol.Barcode.ReaderDataLengths.MaximumLabel)


' create event handler delegate
Me.MyEventHandler = New System.EventHandler(AddressOf
MyReader_ReadNotify)

'Enable reader, with wait cursor
Me.MyReader.Actions.Enable()

'Me.MyReader.Parameters.Feedback.Success.BeepTime = 0
'Me.MyReader.Parameters.Feedback.Success.WaveFile = "\\windows\
\alarm3.wav"

AddHandler Me.Activated, New EventHandler(AddressOf
FrmTrxn2_Activated)
AddHandler Me.Deactivate, New EventHandler(AddressOf
frmtrxn2_Deactivate)


Return True

End Function

'Stop reading and disable/close reader

Private Sub TermReader()

'If we have a reader
If Not (Me.MyReader Is Nothing) Then

'Disable reader, with wait cursor
Me.MyReader.Actions.Disable()

'free it up
Me.MyReader.Dispose()

' Indicate we no longer have one
Me.MyReader = Nothing

End If

' If we have a reader data
If Not (Me.MyReaderData Is Nothing) Then

'Free it up
Me.MyReaderData.Dispose()

'Indicate we no longer have one
Me.MyReaderData = Nothing

End If

End Sub

'Start a read on the reader

Private Sub StartRead()

'If we have both a reader and a reader data
If Not ((Me.MyReader Is Nothing) And (Me.MyReaderData Is
Nothing)) Then

'Submit a read
AddHandler MyReader.ReadNotify, Me.MyEventHandler

Me.MyReader.Actions.Read(Me.MyReaderData)

End If

End Sub

'Stop all reads on the reader

Private Sub StopRead()

'If we have a reader
If Not (Me.MyReader Is Nothing) Then

'Flush (Cancel all pending reads)
RemoveHandler MyReader.ReadNotify, Me.MyEventHandler

Me.MyReader.Actions.Flush()

End If

End Sub

'Read complete or failure notification

Private Sub MyReader_ReadNotify(ByVal o As Object, ByVal e As
EventArgs)

Dim TheReaderData As Symbol.Barcode.ReaderData =
Me.MyReader.GetNextReaderData()

'If it is a successful read (as opposed to a failed one)
If (TheReaderData.Result = Symbol.Results.SUCCESS) Then

'Handle the data from this read
Me.HandleData(TheReaderData)

'Start the next read
Me.StartRead()

End If

End Sub

'Handle data from the reader

Private Sub HandleData(ByVal TheReaderData As
Symbol.Barcode.ReaderData)
Try


Dim S as string
S= TheReaderData.Text

Catch ex As Exception
End Try


End Sub

' Called when the form is activated. This will occur when the
form becomes the current application.
Private Sub FORM_Activated(ByVal sender As Object, ByVal e As
EventArgs) Handles Me.Activated
'If there are no reads pending on MyReader start a new read
If Not Me.MyReaderData Is Nothing Then
If Not (Me.MyReaderData.IsPending) Then

Me.StartRead()

End If
End If

End Sub


And then Add this to Your Form Load Event

Try
If (Me.InitReader()) Then
'Start a read on the reader
Me.StartRead()
End If
Catch ex As Exception
'MsgBox("Scanner is not Available on this Device")
End Try

In the Hadle data sub you can open your other form
Dim F as new Form2
F.show

I hope all this helps

From: Olexandr Kravets on
Thank you for fast response !
But ...

Actually, I do the same what you suggested. If you look at example
CS_ScanSample3 from Symbol, it is look similar.

I have 2 choices.
1. Use one reader, like in CS_ScanSample3. I am able to scan on first form,
then from handler I show another form and then I am not able to scan. I am
sending you packed solution with example. You could test by yourself and
review code.

2. Use on every form new reader. I was using this approach before, but with
SMDK 1.3 and higher I have this issue:

http://support.symbol.com/support/search.do?cmd=displayKC&docType=kc&externalId=MCD-01360&sliceId=SAL_Public&dialogID=7328225&stateId=1%200%207326267

and I don't know how to avoid this problem. I need to actions.enable on
every form, otherwise I am not able to scan.

Any ideas?

Thanks, Olexandr !
From: Olexandr Kravets on
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace MultiScanForm
{
public partial class MainForm : Form
{
private System.EventHandler FormEventHandler;

public MainForm()
{
InitializeComponent();
}


private void MainForm_Load(object sender, EventArgs e)
{
if (Scanning.InitReader())
{
// Create a new delegate to handle scan notifications
FormEventHandler = new EventHandler(MyReader_ReadNotify);
// Set the event handler of the Scanning class to our delegate
Scanning.MyEventHandler = FormEventHandler;
}
else
{
this.Close();
return;
}
}

/// <summary>
/// Read complete or failure notification
/// </summary>
private void MyReader_ReadNotify(object sender, EventArgs e)
{
Symbol.Barcode.ReaderData TheReaderData = Scanning.MyReaderData;

// If it is a successful read (as opposed to a failed one)
if (TheReaderData.Result == Symbol.Results.SUCCESS)
{
FirstChildForm firstChildForm = new
FirstChildForm(TheReaderData.Text);
firstChildForm.ShowDialog();
firstChildForm.Dispose();
}
}

private void MainForm_Closed(object sender, EventArgs e)
{
Scanning.TermReader();
}


private void MainForm_Activated(object sender, EventArgs e)
{
// Reset the scan event handler for the Scanning object to the form's
delegate.
Scanning.MyEventHandler = FormEventHandler;

// Start the next read
Scanning.StartRead("MainForm.Activated");
}


private void MainForm_Deactivate(object sender, EventArgs e)
{
Scanning.StopRead("MainForm.MainForm_Deactivate");
}
}
}
From: Olexandr Kravets on
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace MultiScanForm
{
public partial class FirstChildForm : Form
{
private System.EventHandler FormEventHandler;

public FirstChildForm(string label)
{
InitializeComponent();
textBox1.Text = label;
}

private void FirstChildForm_Load(object sender, EventArgs e)
{
// Create a new delegate to handle scan notifications
FormEventHandler = new EventHandler(FirstChildForm_ReadNotify);
// Set the event handler of the Scanning class to our delegate
Scanning.MyEventHandler = FormEventHandler;
}

private void FirstChildForm_ReadNotify(object sender, EventArgs e)
{
Symbol.Barcode.ReaderData TheReaderData = Scanning.MyReaderData;

// If it is a successful read (as opposed to a failed one)
if (TheReaderData.Result == Symbol.Results.SUCCESS)
{
SecondChildForm secChildForm = new
SecondChildForm(TheReaderData.Text);
secChildForm.ShowDialog();
secChildForm.Dispose();
}
}

private void FirstChildForm_Activated(object sender, EventArgs e)
{
// Reset the scan event handler for the Scanning object everytime the
form is activated
Scanning.MyEventHandler = this.FormEventHandler;

// Start the next read
Scanning.StartRead("FirstChildForm_Activated");
}

private void FirstChildForm_Deactivate(object sender, EventArgs e)
{
Scanning.StopRead("FirstChildForm_Deactivate");
}
}
}