Detecting FN-Buttons

This question is answered

Hello!

I use a Workabout Pro3 with WindowsCE, Compact Framework 2.
I want to show my users if one of the FN-Buttons (Orange, Blue) is active. To achieve this, i use Keyboard.ModifierKeyEventArgs:

AddHandler PsionTeklogix.Keyboard.Keyboard.ModifierKeyEvent, AddressOf Keyboard_ModifierKey
[...]
Private Sub Keyboard_ModifierKey(ByVal sender As Object, ByVal eventArgs As PsionTeklogix.Keyboard.ModifierKeyEventArgs)
Select Case eventArgs.key
[...]
End Select

End Sub

But the event is never fired. What do i do wrong?

Thanks,
Jens 

Verified Answer
  • Good morning Jens,

    Could you please give the attached VS2008 VB .NET demo solution a try and let us know how ot goes form your end?

      MDSDK v5.4 - VS2008 VB .NET GetModifierKeyEvents [DEMO] Solution (compressed)

    --

    & As modifier keys are pressed, you shall get similar info:

      

    --

    FYI: source code reads as follows:

    Imports PsionTeklogix.Keyboard

    Public Class Form1

        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

            chkAlt.Checked = (Keyboard.GetModifierKeyState(Key.Alt) <> KeyState.Off)
            chkControl.Checked = (Keyboard.GetModifierKeyState(Key.Control) <> KeyState.Off)
            chkShift.Checked = (Keyboard.GetModifierKeyState(Key.Shift) <> KeyState.Off)
            chkFnBlue.Checked = (Keyboard.GetModifierKeyState(Key.Blue) <> KeyState.Off)
            chkFnOrange.Checked = (Keyboard.GetModifierKeyState(Key.Orange) <> KeyState.Off)

            AddHandler Keyboard.ModifierKeyEvent, AddressOf OnModifierKeyEvent
            ListBox1.Focus()

        End Sub

        Private Sub OnModifierKeyEvent(ByVal sender As Object, ByVal eventArgs As PsionTeklogix.Keyboard.ModifierKeyEventArgs)

            ListBox1.Items.Add(String.Format("{0}: {1}", eventArgs.key, eventArgs.newState))
            ListBox1.SelectedIndex = ListBox1.Items.Count - 1

            chkAlt.Checked = (Keyboard.GetModifierKeyState(Key.Alt) <> KeyState.Off)
            chkControl.Checked = (Keyboard.GetModifierKeyState(Key.Control) <> KeyState.Off)
            chkShift.Checked = (Keyboard.GetModifierKeyState(Key.Shift) <> KeyState.Off)
            chkFnBlue.Checked = (Keyboard.GetModifierKeyState(Key.Blue) <> KeyState.Off)
            chkFnOrange.Checked = (Keyboard.GetModifierKeyState(Key.Orange) <> KeyState.Off)

        End Sub

        Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
            ListBox1.Items.Clear()
        End Sub

        Private Sub Form1_Closing(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
            RemoveHandler Keyboard.ModifierKeyEvent, AddressOf OnModifierKeyEvent
        End Sub

    End Class

    Regards,
    Jacques

All Replies
  • Good morning Jens,

    Could you please give the attached VS2008 VB .NET demo solution a try and let us know how ot goes form your end?

      MDSDK v5.4 - VS2008 VB .NET GetModifierKeyEvents [DEMO] Solution (compressed)

    --

    & As modifier keys are pressed, you shall get similar info:

      

    --

    FYI: source code reads as follows:

    Imports PsionTeklogix.Keyboard

    Public Class Form1

        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

            chkAlt.Checked = (Keyboard.GetModifierKeyState(Key.Alt) <> KeyState.Off)
            chkControl.Checked = (Keyboard.GetModifierKeyState(Key.Control) <> KeyState.Off)
            chkShift.Checked = (Keyboard.GetModifierKeyState(Key.Shift) <> KeyState.Off)
            chkFnBlue.Checked = (Keyboard.GetModifierKeyState(Key.Blue) <> KeyState.Off)
            chkFnOrange.Checked = (Keyboard.GetModifierKeyState(Key.Orange) <> KeyState.Off)

            AddHandler Keyboard.ModifierKeyEvent, AddressOf OnModifierKeyEvent
            ListBox1.Focus()

        End Sub

        Private Sub OnModifierKeyEvent(ByVal sender As Object, ByVal eventArgs As PsionTeklogix.Keyboard.ModifierKeyEventArgs)

            ListBox1.Items.Add(String.Format("{0}: {1}", eventArgs.key, eventArgs.newState))
            ListBox1.SelectedIndex = ListBox1.Items.Count - 1

            chkAlt.Checked = (Keyboard.GetModifierKeyState(Key.Alt) <> KeyState.Off)
            chkControl.Checked = (Keyboard.GetModifierKeyState(Key.Control) <> KeyState.Off)
            chkShift.Checked = (Keyboard.GetModifierKeyState(Key.Shift) <> KeyState.Off)
            chkFnBlue.Checked = (Keyboard.GetModifierKeyState(Key.Blue) <> KeyState.Off)
            chkFnOrange.Checked = (Keyboard.GetModifierKeyState(Key.Orange) <> KeyState.Off)

        End Sub

        Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
            ListBox1.Items.Clear()
        End Sub

        Private Sub Form1_Closing(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
            RemoveHandler Keyboard.ModifierKeyEvent, AddressOf OnModifierKeyEvent
        End Sub

    End Class

    Regards,
    Jacques

  • Hello Jacques,

    thank you for the example. This demo works fine. So i have to double check where i made a mistake in my Project. But now i know, theoretical it has to work this way...

    Regards,
    Jens 

  •   Hello every one,

    Do you, please, have the same demo in C++ ?

    I'm on PsionNEO CE5.0 and I'm using Microsoft Embedded Visual C++.

    I can't find the GetModifierKeyState in the Keyboard namespaca, so I hope your demo will help me.

    Thank you.

    Frédéric.

  • Bonjour Frédéric,

    Here follows an excerpt of our Mobile Devices SDK version 5.4, C++ Compiled HTML Help File [1]

    DllSpecification KeyState PsionTeklogix::Keyboard::GetModifierKeyState  ( Key  key  )  

    Retrieve current state of modifier key.

    Parameters:
    key  the modifier key to retrieve status. Possible values are: Key_Alt,Key_Blue,Key_Control,Key_Orange or Key_Shift.

    Returns:
    The modifier key state. Possible values are: KeyState_Off,KeyState_OneShot or KeyState_Lock.

    Exceptions:
    std:runtime_error  If device doesn't support this operation. 

    I do hope this helps.
    Kind regards,

    Jacques

    --

    [1] C:\Program Files\Psion\Mobile Devices SDK V5.4\documentation\Cpp\cpp_api.chm

  •   Bonjour Jacques !

    I have downloaded the MDSDK5.4 from this site, try to install it !

    I'm lost with the .hpp and dlls because  I'm suck here :

    #if _COMPILE == PSION_TEKLOGIX_WAP_50
        PsionTeklogix::Keyboard::GetModifierKeyState(PsionTeklogix::Keyboard::Key::Key_Orange);
    #endif

    and got this :

    EmulTxWCEDlg.cpp
    C:\ProjetsPalm\EmulTxWCE 3.4.x\EmulTxWCEDlg.cpp(3011) : error C2039: 'Key_Orange' : is not a member of 'Key'
            c:\projetspalm\emultxwce 3.4.x\ptxkeyboard.hpp(58) : see declaration of 'Key'
    C:\ProjetsPalm\EmulTxWCE 3.4.x\EmulTxWCEDlg.cpp(3011) : error C2065: 'Key_Orange' : undeclared identifier
    Error executing clarm.exe.

    Thanks for your help anyway !

    Frédéric.

  • Frédéric,

    Could you please give the attached VS2008 C++ DEMO solution a try and let us know how it goes from your end?

      MDSDK v5.4 - VS2008 C++ Get Modifier Key Events [DEMO] Solution (compressed)

    E.g.

    Regards,
    Jacques

  • Jacques,

    I use Microsoft Embeded C++ for the CE5 developement so the .sln is not recognized.

    I'll try on Monday to put it on a VS2008 station, I must go !!

    Thanks for your help.

    Frédéric.

  • Oups! Embarrassed

    I totally missed your below statement

    A2iTeam
    I'm using Microsoft Embedded Visual C++.

    As our Mobile Devices SDK 3.x and 5.x C++ libraries have been built with Visual Studio 2005 and Visual Studio 2008, you won't be able to use Microsoft eMbedded Visual C++ 4.0 to link against these. 

    C:\Program Files\Psion\Mobile Devices SDK V5.4\windows ce 5.00>tree /a /f
    Folder PATH listing for volume OS
    Volume serial number is 0030002E AC8A:2E84
    C:.
    |   PtxSdkCommon.dll
    |   PtxSdkWlanExCommon.dll
    |   PtxSdkWwanCommon.dll
    |
    +---studio2005
    |       PtxRemoteSock.dll
    |       PtxRemoteSock.lib
    |       PtxSdkCpp.dll
    |       PtxSdkCpp.lib
    |       PtxSdkWlanExCpp.dll
    |       PtxSdkWlanExCpp.lib
    |       PtxSdkWwanCpp.dll
    |       PtxSdkWwanCpp.lib
    |
    \---Studio2008
            PtxRemoteSock2008.dll
            PtxRemoteSock2008.lib
            PtxSdkCpp2008.dll
            PtxSdkCpp2008.lib
            PtxSdkWlanExCpp2008.dll
            PtxSdkWlanExCpp2008.lib
            PtxSdkWwanCpp2008.dll
            PtxSdkWwanCpp2008.lib

     --

    If you wish to keep developping with eVC++ 4.0, please make sure to download and use our Mobile Devices SDK 2.02

    Kind regards,
    Jacques

  • Good afternoon Frédéric,

    Same as before, but this time, I used Microsoft eMbedded Visual C++ 4.0 and Psion Mobile Devices SDK version 2.02 libraries for CE 5.0 to build the Get Modifier Key Events demo program.

      MDSDK v2.02 - eVC++ 4.0 Get Modifier Key Events [DEMO] Solution for CE 5.0 (compressed)

    --

    & Note

    Prior to executing this program against your Psion Windows CE 5.0 handheld computer, make sure to copy the PtxSdkCommon.dll and PtxSdkCpp.dll libraries - located in the .\MDSDK v2.02 - Windows CE 5.00 folder - to the \Windows or application folder of your CE device.

    --

    Regards,
    Jacques

  • Hello Jacques,

    SDK downloaded and installed. Your demo works on my Neo via the embedded !!

    I willa analyse your code and put it into my software!

    Thank you, you saved me :)

    Bests regards

    Frédéric.

  • Hello Jacques,


    I'm back on the topic.

    The demo works really fine.

    But now it's the previous code who doesn't work anymore and I'm lost qith alla the version of PsionTeklogix.hpp, PtxSdkCpp.lib, PtxSdkCommon.dll, PtxSdkCpp.dll.

    I have this error :
    error LNK2001: unresolved external symbol "public: virtual void __cdecl PsionTeklogix::Scanner::ScannedDataReceiver::DoubleClickEventCallback(class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std
    ::allocator<unsigned short> > const &)" (?DoubleClickEventCallback@ScannedDataReceiver@Scanner@PsionTeklogix@@UAAXABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@Z)
    ARMV4IRelICE/EmulTxWCE.exe : fatal error LNK1120: 1 unresolved externals

    To avoid it I must use the
    PsionTeklogix.hpp 77ko !!

    If I use the 326Ko version -> Failed.

    Any Ideas ?

    Best regards.

    Frédéric.

  • Frédéric,

    Which development tool (eVC++, VS2005 or VS2008) and Mobile Devices SDK version are you currently using?

    Regards,
    Jacques

  •   Jacques,

    eVC++4 and PsioTeckoligxCE500.

    But I've so many sdk installed, how to be sure of the one used ?

    Thanks for your help.

    Frédéric.

  • Frédéric,

    As per the first statements (1) found in the eVC++ sample I posted here on May 11, please

    • compile your C++ projects, using the Mobile Devices SDK version 2.02 header files:

      C:\Program Files\Psion Teklogix\Mobile Devices SDK V2.02\Cpp

    • link your C++ projects against the he Mobile Devices SDK version 2.02 - Windows CE 5.0 PtxSdkCpp.lib library

      C:\Program Files\Psion Teklogix\Mobile Devices SDK V2.02\Windows CE 5.00

    vvvv

    (1) Get Modifier Key Events.cpp excerpt

    /*
     * READ THIS FIRST
     *
     * Prior to executing this eVC++ program against your Psion Windows CE 5.0
     * handheld computer, make sure to copy the PtxSdkCommon.dll and PtxSdkCpp.dll
     * libraries to your CE device (to the \Windows or application folder).
     *
     */

    #include <windows.h>

    #include "Get Modifier Key Events.h"

    #include ".\\MDSDK v2.02 - Cpp\\PsionTeklogix.hpp"

    #pragma comment(lib, ".\\MDSDK v2.02 - Windows CE 5.00\\PtxSdkCpp.lib")

    using namespace PsionTeklogix::Keyboard;

    [...]

    vvvv

    Last but not least, please take a moment to browse the « Using and Deploying Psion Libraries/DLLs » knowledge base article and/or our « Development Kits and Environments » knowledge base section.

    Regards,
    Jacques

  • Ok thanks, first of all, your demo works fine with my eVC++ and the sdk installed !

    WIth the hpp and the lib in the .\\MDSDK v2.02 - Cpp\\  in the directory, and I can launch It and debug, no problem.

    My probleme is when I compil my project with the new hpp, and I've put the 2 directories MSDK...cpp and MSDK...CE 5.00 in my project directory.

    Add the same lines as yours in my cpp, so ...