Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Shift State - solution
Message
From
06/02/2019 15:50:55
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Shift State - solution
Miscellaneous
Thread ID:
01665978
Message ID:
01665978
Views:
74
Likes (1)
I solved the shift state issue I had. The ShiftState() fuction returns a integer with the bits set to the bit set to whether the Shift, Ctrl, Alt key are currently depressed. I know, I know, I should not have had to explain the obvious, but...
CLEAR
DO WHILE INKEY(1)#27
    ? bitshow(ShiftState(),3)
ENDDO

PROCEDURE ShiftState
    DECLARE INTEGER GetKeyState IN user32 INTEGER nVirtKey
    LOCAL nBit AS INTEGER
    nBit = 0
    nBit = IIF(BITTEST(GetKeyState( 0x10 ),8),BITSET(nBit,0),nBit)    && Shift
    nBit = IIF(BITTEST(GetKeyState( 0x11 ),8),BITSET(nBit,1),nBit)    && Ctrl
    nBit = IIF(BITTEST(GetKeyState( 0x12 ),8),BITSET(nBit,2),nBit)    && Alt
    RETURN nBit
ENDPROC

PROCEDURE bitshow
    LPARAMETERS tn AS LONG , nlen AS INTEGER
    LOCAL s, i
    mlen = IIF(EMPTY(nlen),32,nlen)
    s = []
    FOR i=0TO 31
        s = IIF(BITTEST(tn,i),[1],[0]) + s
    NEXT
    RETURN RIGHT(s,nlen)
ENDPROC
Another tool for your toolbox.
Greg Reichert
Next
Reply
Map
View

Click here to load this message in the networking platform