Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Print Screen in VFP app
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00960436
Message ID:
00960720
Views:
38
Prior to VFP9 all you can do is to call GetAsyncKeyState API:
#DEFINE VK_SNAPSHOT 0x2c

DECLARE INTEGER GetAsyncKeyState IN user32 INTEGER vKey
? GetAsyncKeyState(VK_SNAPSHOT)
If PrtScr has been recently pressed, the GetAsyncKeyState returns 1. Though you have to call this function in a cycle or through a timer to react to this event.

There is another API call -- RegisterHotkey -- that can define a system-wide hot key.
DECLARE INTEGER RegisterHotKey IN user32;
	INTEGER hWnd, INTEGER id,;
	INTEGER fsModifiers, INTEGER vk
The first parameter is the handle to a window. That can be either FoxPro form or the main Visual FoxPro window. For example:
LOCAL hWindow
hWindow = _Screen.HWnd
= RegisterHotKey(hWindow, 0, 0, VK_SNAPSHOT)
* ... somewhere later ...
= UnregisterHotKey(hWindow, 0)
After the RegisterHotKey returns, this window starts receiving WM_HOTKEY message each time the PrtScr key is pressed. Not much you can get from this fact in VFP8 unless you use some FLLs.

In VFP9 the BINDEVENT() allows to bind the WM_HOTKEY message to a certain FoxPro code. This technique is described in "Is It Windows or Is It VFP?" article by Drew Speedie published in November 2004 issue of the FoxPro Advisor at http://foxproadvisor.com/doc/14739.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform