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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Functions Key(s) 1

Status
Not open for further replies.

alisaif

ISP
Apr 6, 2013
418
AE
Hi,

I was using f2 (function key) in Dos (FPD26a) application for quick help. Now the users are so used to it and wishing the same sort of help in VFP9 application instead of right click and showing the Shortcut menu.

Can I use the same in vfp9 by using (on key label f2 do form help1) in dos (on key label f2 do help1) or I have to take some precautionary steps before calling the function keys.

Thanks

Saif
 
Hi Saif,

You can do exactly the same as you were doing in FPD. ON KEY LABEL works just the same.

However, the preferred way to do is to trap the key in the form's Keypress event.

Code:
LPARAMETERS nKeyCode, nShiftAltCtrl
IF nKeyCode = 85
  * Show your Help here
ENDIF

You will also need to set the form's KeyPreview property to .T.

If you have more than one form where you want to put this code, put it in your base form class (if you have one).

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Spefically for HELP the convention in Windows of course if to use F1. F2 is defined differently in different applications, but mainly used for renaming things, eg you rename files/folders in Windows via F2.

If your users are used to DOS they should perhaps rathaer adapt to windows conventions. In the first place you could use both F1 and F2 for calling a help. It's never hurting to allow more than one way to do the same thing.

Bye, Olaf.
 
Thanks for the reply,

I just wanted to let you know that users can use f2 key from any part of the application and in form's Keypress event it will reserve for that particular part. And, if I use keypress in base(mainmenu) form will it trap the function key if I call any modal form?

Thanks

Saif
 
Well,

actually Mike already addressed that, because you write code in a base form class and inherit it, so it works in any form. Also if your form is modal, that poses no further problem.

If you want an overall Help, that is also available when no form runs, just the screen and a menu is active, then rather use the standard Windows CHM help system and read about the SET HELP command.

Bye, Olaf.
 
Yes, that's right. If you want to support F2 from any part of the application, you would have to write the Keypress code in every form. That's why I suggested putting it in your base form class. If you don't have a base form class, then the ON KEY LABEL approach will work fine.

I agree with Olaf about using F1 rather than F2. Even though your users are accustomed to using F2 in your application, they will use F1 in most other Windows apps (e.g. Microsoft Office). So consider offering both F1 and F2, at least to begin with.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Thanks

Yes, I can switch to F1 from F2.

Base form means mainmenu form? If yes, then from there can I trap the key on writing the code only in mainmenu keypress event. And, what about after calling the modal form?

Thanks

Saif
 
Base form means mainmenu form?

No. The base form is the base of your class hierarchy. If you don't know what that is, that suggests that you are not creating your own classes.

When moving from FPD to VFP, the ideal approach is to start out by learning about object-oriented programming, and then plan and create your own classes. However, that's a big step, and goes a long way beyond your original question. For now, I suggest you stay with ON KEY LABEL. But do keep what we've said about classes in mind for the future.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Thanks Mike,

I will keep this suggestion in mind.

Saif
 
Mike,

Thanks. A star for you for the inadvertent solution to a headache I have been having:
You will also need to set the form's KeyPreview property to .T.

Sorry to threadjack, but I just wanted to explain.
I drop an image object on a screen, then let the user fine tune the positioning using Shift+Arrow. I could only get that functionality to work if the functionality was in the keypress event of the command button which toggled that ability on or off. I.e., the last button clicked. I couldn't get it to work if it was in the keypress of the form. I had totally forgotten about that property.



-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top