Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
KeyPress and CTRL+INS
Message
De
03/02/2001 04:51:58
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00471298
Message ID:
00472161
Vues:
28
>Hi!
>
>You can use API functions to test if a certain key is pressed. For example, if you get event in KeyPress that INS key is pressed, you can test if Ctrl, Alt or Shift keys are pressed too to check for combinations. Following is a sample code posted by Jhon Hawkins at the Tek-Tips site in the thread 184-49511.
>
>#DEFINE VK_SHIFT 0x10
>
>DECLARE INTEGER GetKeyState IN WIN32API INTEGER
>
>IF INKEY(0,'M') = 151 AND (GetKeyState(vk_Shift)<0)
> Messagebox('User pressed Shift+Left Mouse',0,'Wazzzup!')
>endif
>

There are lots of keystrokes that are trapped by Windows, never even reaching VFP unless you provide code to hook the Windows Event Loop in another language (Mike Stewart and Christof Lange have both pointed pout that you may be able to get around some of this by continuously polling the message queue using PeekMessage(), but it's not a practical approach, that will essentially kill VFP's performance.) The hooking or Window subclassing mechanisms both require providing a callback, something not doable in straight VFP, but accomplishable using an FLL or ActiveX to provide a callback point; with an ActiveX control, this could trigger an event that you could hook with VFP code using VFPCOM. DesaWare produces an ActiveX control for hooking enumeration functions and other types of callbacks, originally designed for use with VB4, but which works with VFP 6 as well, and a limited version of this ships with Dan Appleman's book on using the Win32 API with VB on CD; I've used it on an experimental basis to do things like hook EnumWindows(), and several people have written FLLs that provide callback handlers in the Files Section.)

Hooking system keystrokes in VFP is not really a feasible proposition using just VFP code, and I'll stick by this statement through the current beta release of VFP7, although things are much better in 7 with a Form hWnd property and the availabilty of the IAccessible interface for VFP native controls there (it's not an option available for VFP5 or 6, and no, I have no idea when VFP7 will ship, or the final mechanisms available for hooking the Windows Event Loop, although I suspect that it may be reachable using .Net resources via the InterOp layer, I have not experimented extensively with using this approach, since I have code now written in C that I can use for hooking the event loop for adding my own message handlers, and no, it's not something I'm interested in publishing.) For people not interested in writing their own C code, purchase Appleman's book; the DesaWare utilities more than pay for the cost of the book, and it's a good guide to Win32 API use.

>
>>I seem to be unable to trap CRTL+INS in a form's KeyPress event
>>(even though CTRL+DEL is trapped as I would expect). Am I missing
>>something? I know that ALT key combinations are ignored by the
>>KeyPress event.
>>
>>Question: Are certain other key combinations, i.e. CRTL+INS, also
>>ignored by a form's KeyPress event? Anyone know where I can find
>>such a list? Thanks!
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform