Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

F10 key acitvates Menu and not Keypress event 1

Status
Not open for further replies.

opticalman

Programmer
Nov 6, 2006
103
US
I am using FVP8

I am converting my 15 year old Clipper program to VFP.

I use the KEYPRESS event to trap for keyboard control of my forms. If I set the forms ShowWindow property to TOPLEVEL, I can trap for the F10 key. If I set the forms ShowWindow property to SHOW IN TOPLEVEL, the F10 key is trapped by the MAIN MENU in the top level form. All of the other keys, and F2 through F12 are trapped as expected. Any suggestions on how to trap F10 in a form set to SHOW IN TOPLEVEL, or shall I just use another function key than F10?

Jim Rumbaugh
 
Hi Jim,

shall I just use another function key than F10?

Yes.

The use of F10 it invoke the menu bar is standard throughout Windows apps. At the risk of temporarily irritiating your ex-Clipper users, I would suggest that you keep it that way.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Mike,
Sometimes I'm supprised about some 'standard Windows keys' like F10 now.
Is there a link to somewhere these are all stated?
-Bart
 
I am not certain how the following might affect other Windows applications (if at all), but here is a function that I call during Startup which gives me a 'blank slate' on which to create my own F-Key settings.

Code:
* ---------------------------------
FUNCTION ClrFKeys
PUSH KEY CLEAR
SET MACKEY TO           && reset macro capability
SET FUNCTION f2  TO ''
SET FUNCTION f3  TO ''
SET FUNCTION f4  TO ''
SET FUNCTION f5  TO ''
SET FUNCTION f6  TO ''
SET FUNCTION f7  TO ''
SET FUNCTION f8  TO ''
SET FUNCTION f9  TO ''
SET FUNCTION f10 TO ''
SET FUNCTION f11 TO ''
SET FUNCTION f12 TO ''

ON KEY LABEL f1 KEYBOARD "{F1}" PLAIN
ON KEY LABEL f2 KEYBOARD "{F2}" PLAIN
ON KEY LABEL f3 KEYBOARD "{F3}" PLAIN
ON KEY LABEL f4 KEYBOARD "{F4}" PLAIN
ON KEY LABEL f5 KEYBOARD "{F5}" PLAIN
ON KEY LABEL f6 KEYBOARD "{F6}" PLAIN
ON KEY LABEL f7 KEYBOARD "{F7}" PLAIN
ON KEY LABEL f8 KEYBOARD "{F8}" PLAIN
ON KEY LABEL f9 KEYBOARD "{F9}" PLAIN
ON KEY LABEL f10 KEYBOARD "{F10}" PLAIN
ON KEY LABEL f11 KEYBOARD "{F11}" PLAIN
ON KEY LABEL f12 KEYBOARD "{F12}" PLAIN
RETURN .T.

Good Luck,
JRB-Bldr
 
Thanks JRBBLDR,

I tried your code, but F10 still fires the main menu. I think I'll take Mike's sugestion and switch my code over to the F12 button.

Jim Rumbaugh
 
You might want to think about moving away from function keys altogether. You'll notice that other than Windows shortcuts, they're not used much any more. That's because (like F10 for menu access) it's hidden.

A better choice is to put things on the menu and then assign them menu shortcuts (like CTRL+C for Copy). That way, options are visible and users have an easy way to learn them.

Tamar
 
Mike,
Thanks. Found short-cuts as pointed to by you.

In addition : Tamar I fully agree. Many Windows shortcut are quit 'unexpected'.

-Bart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top