Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
On Escape
Message
From
28/02/2001 07:43:58
Walter Meester
HoogkarspelNetherlands
 
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Title:
Miscellaneous
Thread ID:
00480291
Message ID:
00480473
Views:
22
Hi ed,

>>
IF CHRSAW() OR MDOWN()
>>   DOEVENTS
>>ENDIF
>
>Actually, I got this from Dave Frankenbach a while before you proposed it; it works in most cases. Another approach is to call the API to check all the Windows virtual keys using a buffer to detect changes:

AFAIK, I was the first one who came to this solution, David proposed the fastdoevents with the help of moving the mouse which unfortunately has some side-effects and does not work in all cases.

>
DECLARE SHORT GetKeyboardState IN USER32 STRING @ lpKeyState
>cKeyboardAtRest = REPL(CHR(0),256)
>cKeyboardStateNow = cKeyboardAtRest
>=GetKeyboardState(@cKeyboardAtRest)
>*
>*  In loop
>*
>=GetKeyboardState(@cKeyboardStateNow)
>IF cKeyboardStateNow # cKeyboardAtRest
>   *  Something happened
>   DOEVENTS
>   =GetKeyboardState(@cKeyboardAtRest)
>ENDIF
>
>I suspect it has less overhead than calling CHRSAW() and MDOWN() - it traps all the virtual keys, not just keystrokes that translate to characters; you can trap pressing Alt, Shift, Ctrl as well, down and up changes.

Good tip! I'll look into this and will do some benchmarking and see if this from a performance point of view is a better solution.

Walter,
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform