Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP6 Form Hotkey Buttons?
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00171337
Message ID:
00171358
Views:
22
>I was wondering if the kind souls here could let me in on the secret to assigning hot keys to form buttons that are picture only. It was so easy in FPW2.6 (of course everything else was harder <grin>).

Haven't tried it with picture buttons, but look at the form's KeyPress method and KeyPreview property.

(Depending of course on what your picture buttons do)
your form's KeyPress method will have code something like:
DO CASE
CASE m.nKeyCode = 18 && PgUp
SKIP -1
NODEFAULT
CASE m.nKeyCode = 3 && PgDn
SKIP
NODEFAULT
OTHERWISE
etc
ENDCASE
and you set the form's KeyPreview property to .T.
(sorry code's not indented)

I've used this method and property in several applications for a client who wants old DOS apps updated with as much keystroke compatibility as possible. It's the only way I know of to assign F1, F2, etc. to the command buttons other than ON KEY LABEL (which I avoided because it doesn't seem very VFPish!) (Well, you could make an equivalent menu option for each button and assign them hot-keys but that gave me other problems.)

One thing to watch out for. If, for example, you're using this method to assign a hot key to a "Save" button (with a picture, of course, not the word save). In the CASE for that key, besides clicking that button, SET FOCUS TO IT, or at least change focus from the current object, to make sure that valid's object fires before the Save button's Click code fires. You have to remember (maybe it's easy for you) that programatically firing a button's click method doesn't change focus from the current object.

Also notice the NODEFAULT keyword within each case, telling VFP not to do what it normally does with the keystroke when it's done doing your code in the CASE. Thanks to Steve Sawyer for pointing that out to me a few months back.
Rich Addison, Micro Vane, Inc., Kalamazoo, MI
Relax, don't worry, have a homebrew.
- Charlie Papazian, The New Complete Joy of Home Brewing
Previous
Reply
Map
View

Click here to load this message in the networking platform