Tags: anissue, application, capture, converting, database, discovered, event, foxpro, key, keypress, microsoft, mysql, onwards, oracle, sql, vfp6, vfp7, vfp9

Keypress event F2 works in VFP6 but not VFP7 onwards

On Database » Microsoft FoxPro

8,703 words with 5 Comments; publish: Tue, 06 May 2008 17:35:00 GMT; (25078.13, « »)

I am converting an application from VFP6 to VFP9 and have discovered an

issue that I hope someone can help with.

I am trying to capture the F2 key being pressed within a textbox on a form

in the keypress event (nKeyCode=-1). This would not work in VFP9 so after

trying many things I built a basic form with one text control and a capture

of the key press events to screen. It appears that in VFP6 the textbox

keypress event happily tells me that F2 has been pressed, however in VFP7

onwards it appears that the F2 is not captured and nothing happens. The ON

KEY LABEL is not active and F3, F4 etc are all working e.g. nKeyCode=-2,

nKeyCode=-3 etc. This happens only with F2 (nKeyCode=-1).

Does anyone know why? Is there something I am missing?

This seems too simple an issue to be a bug?

Thanks

John R.

All Comments

Leave a comment...

  • 5 Comments
    • It will work as long as the standard menu is not available. F2 is used for

      Next Shortcut/Bookmark in VFP7 and above. (under menu Edit/Bookmarks)

      Fred

      Microsoft Visual FoxPro MVP

      "John Roberts" <JohnRoberts.ms-foxpro.questionfor.info.btconnect.com> wrote in message

      news:ddu0hr$qcf$1.ms-foxpro.questionfor.info.nwrdmz01.dmz.ncs.ea.ibs-infra.bt.com...

      >I am converting an application from VFP6 to VFP9 and have discovered an

      > issue that I hope someone can help with.

      > I am trying to capture the F2 key being pressed within a textbox on a form

      > in the keypress event (nKeyCode=-1). This would not work in VFP9 so after

      > trying many things I built a basic form with one text control and a

      > capture

      > of the key press events to screen. It appears that in VFP6 the textbox

      > keypress event happily tells me that F2 has been pressed, however in VFP7

      > onwards it appears that the F2 is not captured and nothing happens. The ON

      > KEY LABEL is not active and F3, F4 etc are all working e.g. nKeyCode=-2,

      > nKeyCode=-3 etc. This happens only with F2 (nKeyCode=-1).

      > Does anyone know why? Is there something I am missing?

      > This seems too simple an issue to be a bug?

      > Thanks

      > John R.

      >

      #1; Tue, 06 May 2008 17:37:00 GMT
    • Thank you for your reply (Fred).

      In my application we are still including the _MEDIT menu pad.

      i.e. set sysmenu to _MEDIT, _MWINDOW

      and then other of our own menus added to this via PRG code.

      Then options are removed from the _MEDIT menu e.g.

      RELEASE BAR _MED_SP300 OF _MEDIT

      RELEASE BAR _MED_FIND OF _MEDIT

      RELEASE BAR _MED_REPL OF _MEDIT

      RELEASE BAR _MED_FINDA OF _MEDIT

      RELEASE BAR _MED_REPLA OF _MEDIT

      RELEASE BAR _MED_SP400 OF _MEDIT

      RELEASE BAR _MED_LISTMEMBERS OF _MEDIT

      RELEASE BAR _MED_QUICKINFO OF _MEDIT

      RELEASE BAR _MED_SP500 OF _MEDIT

      RELEASE BAR _MED_BKMKS OF _MEDIT

      RELEASE BAR _MED_SP600 OF _MEDIT

      RELEASE BAR _MED_INSOB OF _MEDIT

      RELEASE BAR _MED_OBJ OF _MEDIT

      RELEASE BAR _MED_LINK OF _MEDIT

      RELEASE BAR _MED_SP700 OF _MEDIT

      RELEASE BAR _MED_PREF OF _MEDIT

      However, it appears that not all menu items get removed as per the commands

      above.

      I get the errors with the above commands "Variable '_MED_SP600' is not

      found." and "Variable '_MED_SP700' is not found."

      When I remove the lines with _MED_SP600 and _MED_SP700, I get these two

      lines in the menu.

      However the bigger issue is that the "BookMarks" options still appear and

      are not removed whether the above error lines are in the code or not.

      So my question. How can I remove the "BookMarks" from the system _MEDIT menu

      so that I can regain control of the F2 key.

      I would rather do this than build a custom _MEDIT menu with a new name as

      the _MEDIT menu it integral to other code in the

      system and would rather use that than do more re-writing to make it work in

      VFP9.

      Thanks

      John R.

      "Fred Taylor" <ftaylor.ms-foxpro.questionfor.info.mvps.org!REMOVE> wrote in message

      news:eJ5taItoFHA.572.ms-foxpro.questionfor.info.TK2MSFTNGP15.phx.gbl...

      > It will work as long as the standard menu is not available. F2 is used

      > for Next Shortcut/Bookmark in VFP7 and above. (under menu Edit/Bookmarks)

      > --

      > Fred

      > Microsoft Visual FoxPro MVP

      >

      > "John Roberts" <JohnRoberts.ms-foxpro.questionfor.info.btconnect.com> wrote in message

      > news:ddu0hr$qcf$1.ms-foxpro.questionfor.info.nwrdmz01.dmz.ncs.ea.ibs-infra.bt.com...

      >

      #2; Tue, 06 May 2008 17:38:00 GMT
    • It would be easier to build a new QuickMenu with everything in it and remove

      what you don't want from it in the code, rather than trying to remove from

      the standard menu at runtime.

      Fred

      Microsoft Visual FoxPro MVP

      "John Roberts" <JohnRoberts.ms-foxpro.questionfor.info.btconnect.com> wrote in message

      news:dduuul$1u7$1.ms-foxpro.questionfor.info.nwrdmz01.dmz.ncs.ea.ibs-infra.bt.com...

      > Thank you for your reply (Fred).

      > In my application we are still including the _MEDIT menu pad.

      > i.e. set sysmenu to _MEDIT, _MWINDOW

      > and then other of our own menus added to this via PRG code.

      > Then options are removed from the _MEDIT menu e.g.

      > RELEASE BAR _MED_SP300 OF _MEDIT

      > RELEASE BAR _MED_FIND OF _MEDIT

      > RELEASE BAR _MED_REPL OF _MEDIT

      > RELEASE BAR _MED_FINDA OF _MEDIT

      > RELEASE BAR _MED_REPLA OF _MEDIT

      > RELEASE BAR _MED_SP400 OF _MEDIT

      > RELEASE BAR _MED_LISTMEMBERS OF _MEDIT

      > RELEASE BAR _MED_QUICKINFO OF _MEDIT

      > RELEASE BAR _MED_SP500 OF _MEDIT

      > RELEASE BAR _MED_BKMKS OF _MEDIT

      > RELEASE BAR _MED_SP600 OF _MEDIT

      > RELEASE BAR _MED_INSOB OF _MEDIT

      > RELEASE BAR _MED_OBJ OF _MEDIT

      > RELEASE BAR _MED_LINK OF _MEDIT

      > RELEASE BAR _MED_SP700 OF _MEDIT

      > RELEASE BAR _MED_PREF OF _MEDIT

      > However, it appears that not all menu items get removed as per the

      > commands above.

      > I get the errors with the above commands "Variable '_MED_SP600' is not

      > found." and "Variable '_MED_SP700' is not found."

      > When I remove the lines with _MED_SP600 and _MED_SP700, I get these two

      > lines in the menu.

      > However the bigger issue is that the "BookMarks" options still appear and

      > are not removed whether the above error lines are in the code or not.

      > So my question. How can I remove the "BookMarks" from the system _MEDIT

      > menu so that I can regain control of the F2 key.

      > I would rather do this than build a custom _MEDIT menu with a new name as

      > the _MEDIT menu it integral to other code in the

      > system and would rather use that than do more re-writing to make it work

      > in VFP9.

      > Thanks

      > John R.

      > "Fred Taylor" <ftaylor.ms-foxpro.questionfor.info.mvps.org!REMOVE> wrote in message

      > news:eJ5taItoFHA.572.ms-foxpro.questionfor.info.TK2MSFTNGP15.phx.gbl...

      >

      #3; Tue, 06 May 2008 17:39:00 GMT
    • You didn't test it in the runtime. It works fine for me.

      Build an exe and run that exe from Windows Explorer to test.

      F2 is pre-assigned ONLY IN THE IDE. No matter what you do, by the time you

      get around to doing it the keystroke has already been assigned IN THE IDE.

      That assignment doesn't happen in runtime.

      Dan

      John Roberts wrote:

      > It appears that F2 keypress functionality has been lost irrelevant of

      > whether there is a menu with _MEDIT pad on it or not.

      > I have built a menu as an experiment without the _MEDIT pad and F2

      > still does not return -1 in the keypress event.

      > What I have discovered is that if you have a menu built around the

      > _MSYSMENU that has any of FoxPros owns pad menus e.g.

      > _MFILE, _MWINDOW etc then F2 is disabled as a keypress event. This

      > includes menus built with the "QuickMenu" option as suggested.

      > I have attached a simple form example of the problem. Run the Form

      > press F2 nothing happens, press F3 and it works.

      > This, I would suggest, is a bug.

      > Thanks for your help.

      > John R.

      > "Fred Taylor" <ftaylor.ms-foxpro.questionfor.info.mvps.org!REMOVE> wrote in message

      > news:eLzJZzzoFHA.3960.ms-foxpro.questionfor.info.TK2MSFTNGP12.phx.gbl...

      #4; Tue, 06 May 2008 17:40:00 GMT
    • Thank you.

      I was not testing the system as an .exe but just a .app.

      You are right. Thanks All.

      John R.

      "Dan Freeman" <spam.ms-foxpro.questionfor.info.microsoft.com> wrote in message

      news:%230tnqCBpFHA.468.ms-foxpro.questionfor.info.TK2MSFTNGP15.phx.gbl...

      > You didn't test it in the runtime. It works fine for me.

      > Build an exe and run that exe from Windows Explorer to test.

      > F2 is pre-assigned ONLY IN THE IDE. No matter what you do, by the time you

      > get around to doing it the keystroke has already been assigned IN THE IDE.

      > That assignment doesn't happen in runtime.

      > Dan

      >

      > John Roberts wrote:

      >

      #5; Tue, 06 May 2008 17:41:00 GMT