Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to detect if the shift key (only) is pressed
Message
De
25/07/2013 15:27:18
 
 
À
25/07/2013 14:43:46
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01579180
Message ID:
01579218
Vues:
133
This message has been marked as the solution to the initial question of the thread.
>Sergy,
>I only want to detect if the shift key has been pressed by itself. Your sample is good to determine if I want SHIFT + U (UPPER"U") or SHIFT+F2. No other key combinations necessary. The VFP keypress will not detect a loan shift keypress. The keypress event on the VFP form will not fire if I only press shift.


Untested, but something like this should work:
**********
* In form's Init() event:
*****
    DECLARE SHORT GetAsyncKeyState IN USER32 INTEGER nVKey

    #define WM_KEYDOWN 0x0100
    #define WM_KEYDOWN 0x0101
    BINDEVENT(thisForm.hwnd, WM_KEYDOWN, thisForm, "onWindowsLevelKeyPress")
    BINDEVENT(thisForm.hwnd, WM_KEYUP,   thisForm, "onWindowsLevelKeyPress")


**********
* Then in onWindowsLevelKeyPress()
*****
    LPARAMETERS tnHwnd, tnMsg, tnW, tnL

    #define VK_LSHIFT   0xa0
    #define VK_RSHIFT   0xa1
    *#define VK_LCONTROL    0xa2
    *#define VK_RCONTROL    0xa3
    *#define VK_LMENU   0xa4
    *#define VK_RMENU   0xa5


    **********
    * Check the condition
    *****
        DO CASE
            CASE BITAND(GetAsyncKeyState(VK_RSHIFT), 0x8000) != 0
                * Right shift is down

            CASE BITAND(GetAsyncKeyState(VK_LSHIFT), 0x8000) != 0
               * Left shift is down

            OTHERWISE
                * Neither shift key is down

        ENDCASE
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform