Hi.
I have developed a .NET application for WAP 3 7527C-G2 with Windows CE 5.0 on C# for Compact Framework 2.0.
In some forms I use the central button "scan" to open a menu mapping the scan button to the F14 key using the TranslateToScanCode function included in PsionTeklogikNet.dll that provides Psion Teklogix Mobile Devices SDK on PsionTeklogikNet.dll.
Most of the time this works fine but some times the application throws a NotSupportedException generated by PsionTeklogix.Keyboard.Keyboard.TranslateToScanCode().
This is a part of StackTrace:
Hardware::addKeyMap : [System.NotSupportedException] NotSupportedException
at PsionTeklogix.Keyboard.Keyboard.TranslateToScanCode() at wmsce.Hardware.addKeyMap() at wmsce.fState..ctor()
Here is the code of addKeyMap function that call TranslateToScanCode. Return true is the translation was completed successful.
public static bool addKeyMap(Key psionKey, System.Windows.Forms.Keys winKey) { bool error = false; try { KeyRemapper remapper = new KeyRemapper(); remapper.Add(Keyboard.TranslateToScanCode(psionKey), null, PsionTeklogix.Keyboard.Function.SendCode, (byte)winKey); KeyRemapper.KeyRemapping[] keyRemapping = remapper.GetAllKeyRemappings(); } catch (Exception ex) { error = true; } return !error; }
Does anyone have the same problem or know what can be wrong?
Thanks.
Fabricio.
Good evening Fabricio and welcome to the Community,
Could you please give the attached VS2008 C# solution a try and let me know how it goes from your end?
MDSDK v5.0 - VS2008 CSharp Remap Scanner Key (DEMO) solution
Remapping the device Scanner key is done as follows:
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using PsionTeklogix.Keyboard;namespace csRemapScannerKey{ public partial class Form1 : Form { KeyRemapper kr = null; public Form1() { InitializeComponent(); try { kr = new KeyRemapper(); } catch (Exception ex) { MessageBox.Show("KeyRemapper instantiation failed with " + ex.Message); this.Close(); return; } chkRemapScannerKey.Checked = true; } private void chkRemapScannerKey_CheckStateChanged(object sender, EventArgs e) { if (chkRemapScannerKey.Checked) { try { kr.Add(Keyboard.TranslateToScanCode(Key.Scan), null, Function.SendCode, (int)Keys.RWin); } catch (Exception ex) { MessageBox.Show("kr.Add() failed with " + ex.Message); } } else { try { kr.Remove(Keyboard.TranslateToScanCode(Key.Scan), null); } catch (Exception ex) { MessageBox.Show("kr.Remove() failed with " + ex.Message); } } } private void Form1_Closing(object sender, CancelEventArgs e) { if (chkRemapScannerKey.Checked) chkRemapScannerKey.Checked = false; } }}
Kind regards,Jacques