Foxpert Software Development & Consulting

Menu

Whitepapers
Downloads
Knowlbits
Guineu

2006-06Jun-02

KeyPress Event

Qualifier keys such as ALT, CTRL and SHIFT are prioritized in this order. When the user presses a combination of these three keys, the highest qualifier determines the key code. If, for instance, the ALT key is pressed with SHIFT, the key code is the same as if you pressed the key and just ALT. If the user instead presses SHIFT and CTRL, the key code switches to the CTRL combination. Only when the SHIFT key is pressed, you would end up with the SHIFT key code. The following table clarifies this for the U key:

              nKeyCode  nShiftAltCtrl
U                  117 	0
Shift+U             85 	1
Ctrl+U              21 	2
Alt+U               22 	4
Shift+Ctrl+U        21 	3
Shift+Alt+U         22 	5
Ctrl+Alt+U          22  6
Shift+Alt+Ctrl+U    22  7 (works only intermittently on my laptop)

The exception from the rule above is the SHIFT+ALT combination on keyboards that support an ALTGR key. SHIFT+ALT+Key and ALTGR+Key trigger the KeyPress event with nShiftAltCtrl=0 and the regular key code.

With ALT combinations, the key code corresponds to the physical location on a US keyboard. Pressing the key between T and U on a German keyboard results in a key code of 122, whereas it returns 121 with a US keyboard layout. However, with the ALT key, the key code is 21 in both cases.

This is the same side effect that occurs with ON KEY LABEL and with certain key combination to control child windows such as ALT+hypen (ALT+-) on a US keyboard which requires a German user to press ALT+ß.

Some special keys fire the KeyPress event, as well:

  nKeyCode nShiftAltCtrl
Caps Lock+Shift+Alt 58 6 (not reliable)
  57 5 (not reliable)
Ctrl+Win+Alt 91 7
Shift+Alt+0 11 5

Some codes are identical. However, this doesn't necessarily apply to all qualifier key combinations.

  nKeyCode nShiftAltCtrl
Ctrl++ / Ctrl+Pos1 29 2
Ctrl+H / Ctrl+Del 127 2
Ctrl+W / Ctrl+End 23 2
Ctrl+Left Arrow / Ctrl+Z 26 2
Ctrl+Right Arrow / Ctrl+B 2 2
Alt+0 / Alt+R 19 4
Shift+Alt+0 19 5
Ctrl+J / Ctrl+Enter 10 3
Shift+Ctrl+J 10 3
Shift+Z / Shift+F7 90 1
Shift+T / Shift+F1 84 1
Shift+U / Shift+F2 85 1
Shift+W / Shift+F4 87 1
Shift+Y / Shift+F6 89 1
Shift+X / Shift+F5 88 1
Shift+V / Shift+F3 86 1

The following combination do not work in conjunction with Ctrl or Ctrl+Shift. The first label is the corresponding key on a German keyboard, the second value on a US keyboard

German US
^ '
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
ß -
' =
Ö ;
Ä '
, ,
. .
- /

SHIFT+F10 is the context menu key and therefore returns nKeyCode=93 and nShiftAltCtrl=1.

With CapsLock, the key codes are inverted.

2006-06Jun-01

Pages objects and the activate event

The Activate event of a page fires under the following circumstances:

  • When you switch to another page either by clicking onto the tabs, or by using Ctrl+Tab. However, the Activate event doesn't fire for the initially displayed page. The exception to this rule results from the next one. The Activate event of the first pageframe (in object order) on the form fires.
  • When a form is activated, VFP triggers the Activate event of the first page frame in object order on the form. One pageframe might be the active one (that is, has got the focus), but the Activate event for the first pageframe always fires. The current focus is not related to the Activate event, even though it seems to be a natural combination.

In this situation, the form's Activate event fires after the page's Activate event. You can distinguish between a user navigating between pages and a user navigating between forms by keeping track of the form's Activate and Deactivate events.

Sample code: <Activate.zip>

Object order refers to the order of objects of an class in the VCX. This is the same order in which VFP creates objects. You can control the object order either by cutting and pasting objects on a class, or by using the "Send to Background" and "Bring to Foreground" features.

Previous KnowlBits

RSS

August 2008 (1)

July 2008 (2)

May 2008 (1)

April 2008 (2)

January 2008 (2)

December 2007 (2)

November 2007 (2)

October 2007 (1)

September 2007 (1)

August 2007 (5)

July 2007 (4)

May 2007 (6)

March 2007 (3)

February 2007 (7)

January 2007 (6)

November 2006 (1)

October 2006 (3)

September 2006 (10)

June 2006 (2)

May 2006 (6)

April 2006 (1)

Southwest Fox 2008, Mesa, AZ, October 16 - 19, 2008

Impressum Kontakt Contact