RFID Reader Interface User's Guide
2.3 Extending the Reach
Mobile Readers
36
Function Manual, 12/2010, J31069-D0198-U001-A2-7618
2.3.8
Make it fun: Working keys
Finally, let’s get back to the trigger keys – remember your
RFxxxM
device has plenty of it, on
the left on the right, a big one on top and a pistol grip trigger (if you have a device equipped
with a barcode unit).
Capturing keyboard input as such is easy: We only have to add an event handler to the main
form’s keydown event. And since we want to know when the key is released again we also
add an event handler to the keyup event. The simple code is shown below.
...
// Main Form initialization code
this.K= new System.Windows.Forms.KeyEventHandler(
this.KeyDownHandler);
this.KeyUp += new System.Windows.Forms.KeyUpHandler(
this.KeyDownHandler);
...
However, this code will only work as long as the main form has the focus. Whenever a
control residing on this main form has the focus, we will not get the key events. Therefore,
our demo application uses a simply ‘intercept all controls’ mechanism starting at the main
form. The main form’s constructor invokes CaptureKeys(this).
protected void CaptureKeys(Control control)
{
for (int i = control.Controls.Count - 1; i >= 0; i--)
{
Control c = control.Controls[i] as Control;
if (c != null)
{
c.K= new System.Windows.Forms.KeyEventHandler(
this.KeyDownHandler);
c.KeyUp += new System.Windows.Forms.KeyEventHandler(
this.KeyUpHandler);
CaptureKeys(c);
}
}
}
Now, we only have to check for the right keycode and invoke the correct trigger function.
Содержание SIMATIC RF610M
Страница 2: ......
Страница 8: ...Introduction Mobile Readers 8 Function Manual 12 2010 J31069 D0198 U001 A2 7618 ...
Страница 79: ......