Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Detecting SHIFT or CTRL Key pressed
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00821373
Message ID:
00821660
Views:
18
Sergey,

Thanks for your suggestion. As usual it was a big help. I've learned alot about the GetKeyState function. However I can't get the state of the Shift Key. As a test, I placed the sample code from the message #12649 in my FieldMerge() method. I then called the FieldMerge() method from the DblClick method of my TextBoxes in a couple of columns in a Grid. Both the CTRL and ALT lines work fine. When I hold down the CTRL key and doubleclick the textbox the message appears as it should. But when I try to do that with the SHIFT key nothing happens.

Is SHIFT reserved in some way in VFP? I really want to use the CTRL and SHIFT keys for this function.

Thanks again.
PROCEDURE DblClick
  ThisForm.FieldMerge()
ENDPROC


PROCEDURE FieldMerge()
 DECLARE SHORT GetKeyState in WIN32API INTEGER KEYCODE
 *!* Is shift key pressed?
 IF (GETKEYSTATE(16) < 0)
     MESSAGEBOX("Shift key pressed")
 ENDIF
 *!* Is ctrl key pressed?
 IF (GETKEYSTATE(17) < 0)
     MESSAGEBOX("CTRL key pressed")
 ENDIF
 *!* Is alt key pressed?
 IF (GETKEYSTATE(18) < 0)
     MESSAGEBOX("Alt key pressed")
 ENDIF
ENDPROC
>You can use GetKeyState API #12649.
>
>>I have a grid where in two of the columns I set the DblClick() method of the contained TextBox to a custom method on the form, ThisForm.FieldMerge().
>>
>>However I do not want the method to execute unless the user is holding down either the SHIFT or CTRL key, and depending on which of the two they are pressing while doubleclicking I want to do one of two CASE statements in my custom method.
>>
>>How do I detect which key is "held down" at the time of the DoubleClick. I've read the INKEY(), Keypress, LASTKEY(), etc stuff, but I'm not understanding what is needed.
>>
>>Thank you.
Elgin Rogers
Epic Solutions
www.epicsolutions.net
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform