Some key combinations are not intercepted by keypress().
Some are intercepted only by the form's keypress() but not by the object's keypress() (like ALT+letter).
Also the menu's shortcuts can be ignored (like CTRL+A).
I wrote a little more about keypress here
[link https://www.foxite.com/archives/keypress-and-dodefault-for-textbox-0000412653.htm]Keypress and DODEFAULT() for textbox[/link]
In this case, CTRL+SHIFT+ENTER is used to run an executable as administrator.
Maybe this is the reason for not being intercepted by neither the form's, nor the object's keypress()
To intercept it, the wm_keyup message must be bind to the form's hwnd, and then the GetKeyState() function must be called.
If the highest bit of the returned value of GetKeyState() is equal to 1, then the key passed as parameter was pressed (CTRL or Shift)
I wrote a little more about binding wm_keyup message, here
[link http://praisachion.blogspot.ro/2015/06/detect-keyup-like-mouseup.html]Detect KeyUp like MouseUp()[/link]
Here is the solution for intercepting CTRL+SHIFT+Enter.
[code Foxpro]DECLARE integer GetKeyState IN User32 integer
#define VK_RETURN 0x0d && Enter
#define VK_SHIFT 0x10 && Shift
#define VK_CONTROL 0x11 && Control
#define VK_LSHIFT 0xa0 && Left Shift
#define VK_RSHIFT 0xa1 && Right Shift
#define VK_LCONTROL 0xa2 && Left CTRL
#define VK_RCONTROL 0xa3 && Right CTRL
PUBLIC ofrm
ofrm = CREATEOBJECT("MyForm")
ofrm.show()
DEFINE CLASS MyForm as Form
ADD OBJECT txt as textbox && the desired object
ADD OBJECT cmd as commandbutton WITH top = 50
PROCEDURE Init
BINDEVENT(This.HWnd,0x0101,This,"detectkeyup") && intercept keyup
ENDPROC
PROCEDURE detectkeyup
LPARAMETERS p1,p2,p3,p4
IF TYPE("This.ActiveControl") <> "U"
IF This.ActiveControl = ThisForm.txt AND p3 = VK_RETURN AND BITTEST(GetKeyState(VK_SHIFT),7) AND BITTEST(GetKeyState(VK_CONTROL),7)
* p3 = VK_RETURN && 13 enter
* place here the desired code
* in this sample just type to the screen which shift and control (left or right) was pressed
ACTIVATE SCREEN
?BITTEST(GetKeyState(VK_LSHIFT),7),BITTEST(GetKeyState(VK_LCONTROL),7),BITTEST(GetKeyState(VK_RSHIFT),7),BITTEST(GetKeyState(VK_RCONTROL),7)
ENDIF
ENDIF
ENDPROC
ENDDEFINE[/code]
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.