I'm hoping somebody has some ideas, because I've run out of 'em <g>...
I have an application (Help Builder actually) that needs to capture keyboard input to override stock FoxPro behavior. Specifically I have an editbox that takes over Ctrl-Z and Ctrl-R handling for Undo and Redo because the VFP editbox undo buffer is very limited - basically as soon as the value is updated in any way via code (such as selstate updates or re-writing a value) the undo buffer is gone.
Long story short I use KeyPress to capture these keys and then handle them.
Now there are a number of problems. For one the keycodes for the Ctrl-Z and Ctrl-R overlap with Ctrl-Left and Ctrl-PgDn, so using KeyPress isn't going to help. The nShiftAltCtrl value also doesn't help because the overlap returns the same values since both key combinations use the Ctrl Keys. Smart mapping that <g>...
Anyway I've been using the GetKeyState API to get additional key information about the key pressed, and it works OK in most situations. The problem is that I have a few customers for whom this code just doesn't work as GetKeyState apparently doesn't return the right values.
I've included the code below. Has anybody run into this sort of thing before? Any idea why on some machines/keyboards this wouldn't work? And anybody have any idea how to reliably detect the key codes?
Here's the code:
LPARAMETERS nKeyCode, nShiftAltCtrl
IF nKeyCode = 27
NODEFAULT
ENDIF
IF THIS.lUndoTracking
#DEFINE VK_LEFT 0x25
#DEFINE VK_PGUP 0x21
IF nKeyCode = 26
DECLARE INTEGER GetKeyState IN WIN32API INTEGER
lnKeyState = GetKeyState(VK_LEFT)
IF lnKeyState > -1
THIS.Undo()
NODEFAULT
ENDIF
ENDIF
IF nKeyCode = 18
DECLARE INTEGER GetKeyState IN WIN32API INTEGER
lnKeyState = GetKeyState(VK_PGUP)
IF lnKeyState > -1
THIS.Redo()
NODEFAULT
ENDIF
ENDIF
ENDIF