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

HotKeys Help 3

Status
Not open for further replies.

redzombi5k

Programmer
Jan 21, 2009
22
0
0
US
Hello everyone,
I was just curious how everyone makes hot keys in there programs. For example I would like to make a hot key/shortcut where say the user presses ctrl + s and it auto fills in a story. My problem with that is if I try to use keypress there are so many overlaps there. Say for instance ctrl + s = 19 but that is also Left Arrow.. Not so good!

So any help/suggestions is as always appriciated :)

-Steve
 
Stick with keypress. It's the only way that works WITH the object/event model rather than AGAINST it.
 
How do you overcome the inkeycode overlaps in keypress then?
 
You don't use that many hotkeys. <shrug> If they overlap there, they'll overlap elsewhere too.
 
In keypress you have to specify nShiftAltCtrl as well if using a combination,
CTRL + s =
if nShiftAltCtrl = 2 AND nKeyCode = 19
**** do story
endif
 
Imaginecorp,
Thank You!
That was the perfect solution, I feel dumb for not noticeing this before, I am still exreamly greatfull though, probably never would have noticed this on my own.

-Steve
 
Steve,

Can I just check that you know about using this key combination
Code:
\<
in the caption of buttons?

This creates a shortcut that responds to an Alt key combination.

Stewart
 
First I suggest you better not use CTRL+S, as that is a very common hotkey for Saving a file, eg in notepad, word, excel, foxpro...

If you want something to be a hotkey not only in one form, then define a menu bar with that hotkey, it doesn't have to be visible, just defined.

Code:
Define Popup hotkeys
Define Bar 1 of hotkeys prompt 'story' key alt+s
On Bar 1 of hotkeys MessageBox('story')

Instead of calling the messagebax call a function setting _clipboard and sending KEyboard CTRL+V to paste something.

I only don't know from the top off my head, why this only works once. The popup seems to vanish once used, so either you redefine it everytime or hope I find how to make this permanent. Perhpas define a mnue rather then only a popoup...

Bye, Olaf.
 
StewartUK, No I did not know that. Thank you I will give it a whirl.
Olaf, Also very interesting as I did not know or at least think about this & will try this out as well.

Very cool ideas, and I appriciate all the knowlage!

-Steve
 
StewartUK,
Also interestingly this '\<' works with check boxes as well, which was good for me as I have a few graphical style check boxes that I use for sorting order of a list box control. Very usefull!
Thanks

-Steve
 
Steve - glad you found it useful.

Also see the help topic How to: Assign Access Keys and Keyboard Shortcuts. It doesn't seem say it there, but if you use the \< with a label object caption, VFP will put the cursor in/on the next object in the Tab Order list.

Stewart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top