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

Shortcut Key

Status
Not open for further replies.

jerold

Programmer
Aug 30, 2000
52
PH
Setup:

My form1 contains:
textboxes, comboxes, grids inside pages, etc...

Problem:
Is there a way to create a shortcut key (for a control)
on how to move from a grid to other controls
(e.g. textbox, combox)

Thank you
 
Jerold, the usual way to do this in the Windows is to use underlined letters in the labels. These labels could be accessed quickly using ALT+<letter>, where letter is one of the underlined letters in labels.
Do following:
Use '\<' in the caption of label to underline letter in the caption. For example, you have textbox and label 'Name'. You assign caption for label '\<Name', so it will look like Name.
Rearrange tab order of controls so label that belongs to control will have tab order before tab order of control. For example, label 'Name' should have tab order 2 when textbox for name enterng have tab order 3.

Of course, you can use 'ON KEY LABEL' command to assign any command to the certain keys. Of course, you can use 'KeyPreview' property of form and than write code in 'KeyPress' event of form to trap certain keys and change focus. However, it is not usual way for Windows and used in situations when you have no other choise.


Vlad Grynchyshyn
vgryn@softserve.lviv.ua
The professional level of programmer could be determined by level of stupidity of his/her bugs
 
If I understand you, Jerold, you want some hot key that moves you out of the grid on onto the next control in the tab order.

You might try the Form.Keypress event, and have it trap for a certain key or key combination, then set the focus to the desired control if that key has been pressed.

Robert Bradley

 
If I understand you, Jerold, you want some hot key that moves you out of the grid on onto the next control in the tab order.

Or you could just press CTRL+TAB. ;-) Jon Hawkins
jonscott8@yahoo.com

The World Is Headed For Mutiny,
When All We Want Is Unity. - Creed
 
Or you could just press CTRL+TAB

Well, yeah...if you want to take the easy and simple way out. I just figured Jerold was billing by the hour |-0


Robert Bradley

 
Thank you guys.

Just one question, how would I determine
if the nkeycode is a combination
(e.g. ALT + x)
 
Using keypress, the parameter nKeyCode holds the keycode and the parameter nShiftAltCtrl holds a value indicating if <Shift>, <Alt> or <Ctrl> was held down:
<Shift> = 1, 0001 (bin)
<Alt> = 2, 0010 (bin)
<Ctrl> = 4, 0100 (bin)
(see also the MSDN lib.)

Pressing <Shift>+<Ctrl>+<a> would result in:
nKeyCode : 97
nShiftAltCtrl: 5 (1 + 4)

There is a catch: the keypress event doesn't fire for <Alt>-combinations..... )o:

The only solution I've come up with sofar for trapping <Alt>-combinations is using the Microsoft Forms 2.0 textbox ActiveX, as this control traps all keypresses, but this solution doesn't work in combination with the forms' keypress-event.

Diederik Vermeeren
verm1864@exact.nl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top