Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Catch if shift key pressing at toolbar buttons click met
Message
From
08/03/2014 19:34:44
 
 
To
08/03/2014 17:32:17
Metin Emre
Ozcom Bilgisayar Ltd.
Istanbul, Turkey
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01595966
Message ID:
01595975
Views:
79
Excellent. Thank you for the correction. I've updated my code sample below as well.

>Thank you,
>Just one mistake, it's good with an untested code:
>WAIT WINDOW "Shift keys: " + IIF(BITAND(lnResultL, 0x8000)#0, "Left ", SPACE(0)) +;
> IIF(BITAND(lnResultR, 0x8000)#0, "Right", SPACE(0))
>I'll do just save at form with click and save and exit with shift+click. It'll be good...
#define VK_LSHIFT   0xA0     && Left   SHIFT
#define VK_RSHIFT   0xA1     && Right  SHIFT
#define VK_LCONTROL 0xA2     && Left   CONTROL
#define VK_RCONTROL 0xA3     && Right  CONTROL
#define VK_LMENU    0xA4     && Left   ALT
#define VK_RMENU    0xA5     && Right  ALT
DECLARE SHORT GetAsyncKeyState IN USER32.DLL INTEGER nVKey  && Virtual key-code

* Repeatedly show the key states
DO WHILE .T.
    * Only update every 1/10th second
    lnStart = SECONDS() + 0.10
    DO WHILE SECONDS() < lnStart
    ENDDO

    * Get the key press states
    llShiftL = (BITAND(GetAsyncKeyState(VK_LSHIFT),   0x8000) != 0)
    llShiftR = (BITAND(GetAsyncKeyState(VK_RSHIFT),   0x8000) != 0)
    llCtrlL  = (BITAND(GetAsyncKeyState(VK_LCONTROL), 0x8000) != 0)
    llCtrlR  = (BITAND(GetAsyncKeyState(VK_RCONTROL), 0x8000) != 0)
    llAltL   = (BITAND(GetAsyncKeyState(VK_LMENU),    0x8000) != 0)
    llAltR   = (BITAND(GetAsyncKeyState(VK_RMENU),    0x8000) != 0)

    WAIT WINDOW "Keys: " + ;
                 IIF(llShiftL, "Left Shift ",    SPACE(0)) + ;
                 IIF(llShiftR, "Right Shift ",   SPACE(0)) + ;
                 IIF(llCtrlL,  "Left Control ",  SPACE(0)) + ;
                 IIF(llCtrlR,  "Right Control ", SPACE(0)) + ;
                 IIF(llAltL,   "Left Alt ",      SPACE(0)) + ;
                 IIF(llAltR,   "Right Alt ",     SPACE(0)) NOWAIT

    IF llShiftL AND llShiftR AND llCtrlL AND llCtrlR AND llAltL AND llAltR
        * When all keys are pressed, exit
        EXIT
    ENDIF
ENDDO
CANCEL
>>If you do this as the first operation of your click() event, the shift key will likely still be down so the return value will be valid in that case (if you can't check it any other way).
>>
>>Here are codes also for Shift, Control, and Alt:
>>
>>The other virtual key codes are here:
>>http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731%28v=vs.85%29.aspx
>>
>>You can also obtain the system mouse position similarly using GetCursorPos() (http://msdn.microsoft.com/en-us/library/windows/desktop/ms648390%28v=vs.85%29.aspx ) but it requires some more complex extraction to obtain the offsets. See the post I wrote in my message history about the UTC to Local time for the algorithms to extract the 16-bit portions.
Previous
Reply
Map
View

Click here to load this message in the networking platform