I received this question:

 

Is there any way to detect an F10 keypress in the KeyPress() event?

It looks like F10 is a system key of some sort (ALT?).

 

 

It’s similar to this post: How to hook command window keystrokes

 

I just modified the code a little to hook the WM_SYSKEYDOWN Notification  for a particular form

 

* From C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\winuser.h

 

#define GWL_WNDPROC         (-4)

#define WM_KEYDOWN                      0x0100

#define WM_KEYUP                        0x0101

#define WM_CHAR                         0x0102

#define WM_SYSKEYDOWN                   0x0104

#define WM_SYSKEYUP                     0x0105

#define WM_SYSCHAR                      0x0106

 

 

PUBLIC oMyHook as MyHook

oMyHook=NEWOBJECT("MyHook")

oMyHook.show

DEFINE CLASS MyHook AS form

      dwOrigWindProc=0

      dwShNotify=0

      allowoutput=.f.

      left=300

      PROCEDURE init

            DECLARE integer GetWindowLong IN WIN32API ;

                  integer hWnd, ;

                  integer nIndex

            DECLARE integer CallWindowProc IN WIN32API ;

                  integer lpPrevWndFunc, ;

                  integer hWnd,integer Msg,;

                  integer wParam,;

                  integer lParam

            THIS.dwOrigWindProc =GetWindowLong(_VFP.HWnd,GWL_WNDPROC)

            cWind="Command"

            WDOCKABLE(cWind,.f.)    && make Command window not dockable

 

            BINDEVENT(thisform.HWnd, WM_SYSKEYDOWN,this,"HandleMsg")

            BINDEVENT(thisform.HWnd, WM_SYSKEYUP,this,"HandleMsg")

            BINDEVENT(thisform.HWnd, WM_SYSCHAR,this,"HandleMsg")

      PROCEDURE HandleMsg(hWnd as Integer, msg as Integer, wParam as Integer, lParam as Integer)

            LOCAL nRetvalue

            nRetvalue=0

            ?PROGRAM(),msg,TRANSFORM(wParam,"@0x"),TRANSFORM(lParam,"@0x")," "

            DO case

            CASE lParam=WM_KEYDOWN

            CASE lParam=WM_KEYUP

            CASE lParam=WM_CHAR

            ENDCASE

            nRetvalue=CallWindowProc(this.dwOrigWindProc,hWnd,msg,wParam,lParam)

            RETURN nRetvalue

ENDDEFINE