How to catch F9 and F10 key presses in modal form - keypress

Visual FoxPro 9 modal form KeyPreview property is set to true
I tried in form keypress event
LPARAMETERS nKeyCode, nShiftAltCtrl
messagebox(nKeyCode)
but message box does not appear.
If up arrow or letter is pressed, message box appears.
How to catch F9 and F10 key presses ?

In the VFP IDE, F1, F2 and F10 have reserved behavior and can't seem to be overridden. However, if you compile the form as part of an application, it should work as expected.
EDIT: I tried that, but F10 still would just activate the menu on _SCREEN. F1 and F2 were detected, though.
As a test I made my test form a Top Level form and set SCREEN=OFF in my config.fpw. I then recompiled the program and finally F10 was detected in the KeyPress event.
So there is some kind of built-in behavior you have to work around. You may also see if ON KEY LABEL F10 can be of use.

Related

Intellij: Code highlighted purple in debug mode

Does anyone know what this purple highlighting means in Intellij debug mode?
Immediately after executing this line in the debugger, the program exits with no error message or error thrown.
This is called "Smart Step Into", and allows you to select the method, that you would like to step into for debugging, if there are multiple method calls in a line (like in your example). To use this feature, you would press Shift + F7, and then either click on the method, or use the arrow keys or tab button to choose the method, and then either press Enter or F7 to enter that method.
For reference: https://www.jetbrains.com/help/idea/stepping-through-the-program.html#smart-step-into

How to replace Discard changes with Do you want to save changes

If Esc key is pressed in
MODIFY FILE test
window, Visual FoxPro shows
Discard changes
Yes No
prompt. How can I replace this with
Do you want to save changes to test.txt
Yes No Cancel
prompt ?
A Yes/No/Cancel prompt appears if I click on the close button in the upper right corner of the close window.
Is it possible to force it to appear when I press ESC also ?
Can ON KEY LABEL esc or some custom edit windows command be used or is there some other solution ?
Yes, you could solve it with ON KEY LABEL esc someFunctionCall(). The function has then to display the dialog you desire, and you also have to write the logic whether you pressed Yes, No or Cancel. Also keep in mind, that you have to issue ON KEY LABEL esc again, so the dialog won't show up everywhere.
Another solution would be hitting CTRL+S before you press Escape. With another dialog you have to move the mouse or press another button anyways, so there is no time to safe here.

How does TranslateAccelerator know about CTRL or SHIFT modifier?

I'm working in a program that uses Accelerator keys for user-defined hot keys, and every thing works fine. The user can set hotkeys using SHIFT, CTRL, or ALT. I know that using ALT generates a WM_SYSKEYDOWN rather than WM_KEYDOWN, so it's pretty obvious when ALT is held down.
TranslateAccelerator only takes a window handle, the accel table handle and a single KEYDOWN message. So, my question is, if the user presses CTRL+T, how does TranslateAccelerator know the CTRL key was also pressed?
I know that the CTRL generates a separate KEYDOWN command, and I specifically filtered those out (do not pass to TranslateAccelerator) to test a theory, but TranslateAccelerator is still working.

Binding to Ctrl-Shift in AutoHotKey

I want to use AutoHotKey to bind a command to Ctrl+Shift, in the same way that Windows detects it in order to change text direction from right-to-left to left-to-right. That is: I want it to be invoked when Ctrl+Shift is let go, and only if no keys were pressed between pressing Ctrl+Shift and letting them go.
I bound a hotkey on ^~ Shift Up and I expected it to behave the same way as when Windows binds to it for changing the text direction. But, I found that it gets invoked even in cases where I don't want it to be invoked.
For example, I could be selecting a few words by pressing Ctrl and Shift, and then using the arrow keys. Then I let go of Ctrl and Shift and the hotkey gets invoked. I don't want this. I want a hotkey that gets invoked only if I held nothing else then Ctrl and Shift. If I use any other keys, I want the hotkey not to be invoked.
Is there a way to do this with AHK?
#InstallKeybdHook
Hotkey, ^LShift Up, ControlShiftUp
Return
ControlShiftUp:
if (A_PriorKey != "LShift") ; [v1.1.01+]
return
; do something
msgbox hi
Return

Keycodes of function keys with F-lock off?

Many recent keyboard from Microsoft and Logitech have a so-called F-Lock key, which toggles the function keys F1 to F12 between their traditional keycodes and new meanings that are printed onto the keys: F1=Help F2=Undo F3=Redo F4=Open ... . (See also http://en.wikipedia.org/wiki/F-Lock.)
This means that long-established shortcuts such as Alt+F4 no longer work if the F-lock is off, and googling shows that quite a few people are unhappy about this.
So I'm wondering, what virtual key (VK) codes do the function keys send when F-lock is off? VK_F13 to VK_F24 perhaps? Or do they not trigger standard keyboard events at all?
(I haven't got such a keyboard to try and find out myself, and didn't manage to dig up anything on MSDN about this.)
This article says you can't detect F-lock programmatically
http://jtsang.mvps.org/flock.html
I was just trying to find this out so that I could make an application continue to work with F-Lock off and couldn't find a list so thought I'd post what I found. Rather than any new unique key-codes when F-Lock is off the following conventional key combinations are sent:
F1 = F1 (Help)
F2 = Ctrl+Z (Undo)
F3 = Ctrl+Y (Redo)
F4 = Ctrl+N (New)
F5 = Ctrl+O (Open)
F6 = Ctrl+F4 (Close)
F7 = Ctrl+R (Reply)
F8 = Ctrl+F (Fwd)
F9 = Ctrl+Enter (Send)
F10 = F7 (Spell)
F11 = Ctrl+S (Save)
F12 = Ctrl+P (Print)

Resources