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:55:05
 
 
À
25/07/2013 15:27:18
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:
01579219
Vues:
75
>>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
>
In your .Init code the two DEFINEs are the same - shouldn't one of them be WM_KEYUP?
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform