一个十分简单的问题:键值(30分)

  • 主题发起人 主题发起人 delphi?
  • 开始时间 开始时间
D

delphi?

Unregistered / Unconfirmed
GUEST, unregistred user!
1。各个常用键的键值都是什么?
譬如:Enter=VK_RETURN;
Shift=?
Ctrl=?
2。怎么判断鼠标的左键,或右键的按下?

 
VK_shift 16
vk_control 17
 
Shift = VK_SHIFT
Ctrl = VK_CONTROL
TMouseButton = (mbLeft, mbRight, mbMiddle);
 

1、看看Window单元,内有说明。
2、看看事件中的shift属性(TShiftState)
 
1.
VK_SHIFT
VK_CONTROL

2.
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
i:integer;
begin
i:=0;
if ssLeft in Shift then//表示按下左键
i:=i+1;
if ssRight in Shift then i:=i+2;
if ssMiddle in Shift then i:=i+4;
edit1.Text :=inttostr(i);
end;
 
1.在 Windows 单元中有
VK_LSHIFT = 160;
VK_RSHIFT = 161;
VK_LCONTROL = 162;
VK_RCONTROL = 163;

2.在 OnMouseDown 或 OnMouseUp 事件中判断
 
vk_LButton = $01;

vk_RButton = $02;

vk_Cancel = $03;

vk_MButton = $04; { NOT contiguous with L & RBUTTON }

vk_Back = $08;

vk_Tab = $09;

vk_Clear = $0C;

vk_Return = $0D;

vk_Shift = $10;

vk_Control = $11;

vk_Menu = $12;

vk_Pause = $13;

vk_Capital = $14;

vk_Escape = $1B;

vk_Space = $20;

vk_Prior = $21;

vk_Next = $22;



vk_End = $23;

vk_Home = $24;

vk_Left = $25;

vk_Up = $26;

vk_Right = $27;

vk_Down = $28;

vk_Select = $29;

vk_Print = $2A;

vk_Execute = $2B;

vk_SnapShot = $2C;

{ vk_Copy = $2C not used by keyboards }

vk_Insert = $2D;

vk_Delete = $2E;

vk_Help = $2F;

{ vk_A thru vk_Z are the same as their ASCII equivalents: 'A' thru 'Z' }

{ vk_0 thru vk_9 are the same as their ASCII equivalents: '0' thru '9' }



vk_NumPad0 = $60;

vk_NumPad1 = $61;

vk_NumPad2 = $62;

vk_NumPad3 = $63;

vk_NumPad4 = $64;

vk_NumPad5 = $65;

vk_NumPad6 = $66;

vk_NumPad7 = $67;

vk_NumPad8 = $68;

vk_NumPad9 = $69;

vk_Multiply = $6A;

vk_Add = $6B;

vk_Separator = $6C;

vk_Subtract = $6D;

vk_Decimal = $6E;

vk_Divide = $6F;

vk_F1 = $70;

vk_F2 = $71;

vk_F3 = $72;

vk_F4 = $73;

vk_F5 = $74;



vk_F6 = $75;

vk_F7 = $76;

vk_F8 = $77;

vk_F9 = $78;

vk_F10 = $79;

vk_F11 = $7A;

vk_F12 = $7B;

vk_F13 = $7C;

vk_F14 = $7D;

vk_F15 = $7E;

vk_F16 = $7F;

vk_F17 = $80;

vk_F18 = $81;

vk_F19 = $82;

vk_F20 = $83;

vk_F21 = $84;

vk_F22 = $85;

vk_F23 = $86;

vk_F24 = $87;

vk_NumLock = $90;

vk_Scroll = $91;


VK_0 through VK_9 are the same as ASCII "0" through "9"
(0x30 - 0x39).
VK_1
A virtual key code for the ASCII "1" key.
VK_2
A virtual key code for the ASCII "2" key.
VK_3
A virtual key code for the ASCII "3" key.
VK_4
A virtual key code for the ASCII "4" key.
VK_5
A virtual key code for the ASCII "5" key.
VK_6
A virtual key code for the ASCII "6" key.
VK_7
A virtual key code for the ASCII "7" key.
VK_8
A virtual key code for the ASCII "8" key.
VK_9
A virtual key code for the ASCII "9" key.
VK_A
VK_A through VK_Z are the same as ASCII "A" through "Z"
(0x41 - 0x5A).
VK_ACCEPT
For Asian keyboards.
VK_ADD
A virtual key code for the numeric keypad PLUS SIGN (+)
key.
VK_ALT
A virtual key code for the ALT key.
VK_B
A virtual key code for the ASCII "B" key.
VK_BACK_QUOTE
A virtual key code for the apostrophe (`) key.
VK_BACK_SLASH
A virtual key code for the BACKSLASH (/) key.
VK_BACK_SPACE
A virtual key code for the BACKSPACE key.
VK_C
A virtual key code for the ASCII "C" key.
VK_CANCEL
A virtual key code for the CANCEL key.
VK_CAPS_LOCK
A virtual key code for the CAPS LOCK key.
VK_CLEAR
A virtual key code for the CLEAR key.
VK_CLOSE_BRACKET
A virtual key code for the CLOSE BRACKET (]) key.
VK_COMMA
A virtual key code for the COMMA (,) key.
VK_CONTROL
A virtual key code for the CTRL key.
VK_CONVERT
For Asian keyboards.
VK_D
A virtual key code for the ASCII "D" key.
VK_DECIMAL
A virtual key code for the numeric keypad DECIMAL POINT (.)
key.
VK_DELETE
A virtual key code for the DELETE key.
VK_DIVIDE
A virtual key code for the numeric keypad DIVISION (/) key.
VK_DOWN
A virtual key code for the DOWN ARROW key.
VK_E
A virtual key code for the ASCII "E" key.
VK_END
A virtual key code for the END key.
VK_ENTER
A virtual key code for the ENTER key.
VK_EQUALS
A virtual key code for the EQUAL SIGN (=) key.
VK_ESCAPE
A virtual key code for the ESC key.
VK_F
A virtual key code for the ASCII "F" key.
VK_F1
A virtual key code for the F1 key.
VK_F10
A virtual key code for the F10 key.
VK_F11
A virtual key code for the F11 key.
VK_F12
A virtual key code for the F12 key.
VK_F2
A virtual key code for the F2 key.
VK_F3
A virtual key code for the F3 key.
VK_F4
A virtual key code for the F4 key.
VK_F5
A virtual key code for the F5 key.
VK_F6
A virtual key code for the F6 key.
VK_F7
A virtual key code for the F7 key.
VK_F8
A virtual key code for the F8 key.
VK_F9
A virtual key code for the F9 key.
VK_FINAL
For Asian keyboards.
VK_G
A virtual key code for the ASCII "G" key.
VK_H
A virtual key code for the ASCII "H" key.
VK_HELP
A virtual key code for the HELP key.
VK_HOME
A virtual key code for the HOME key.
VK_I
A virtual key code for the ASCII "I" key.
VK_INSERT
A virtual key code for the INSERT key.
VK_J
A virtual key code for the ASCII "J" key.
VK_K
A virtual key code for the ASCII "K" key.
VK_KANA
For Asian keyboards.
VK_KANJI
For Asian keyboards.
VK_L
A virtual key code for the ASCII "L" key.
VK_LEFT
A virtual key code for the LEFT ARROW key.
VK_M
A virtual key code for the ASCII "M" key.
VK_META
A virtual key code for the Application key (found on
Microsoft? Windows? 95 keyboards).
VK_MODECHANGE
For Asian keyboards.
VK_MULTIPLY
A virtual key code for the numeric keypad MULTIPLICATION
(*) key.
VK_N
A virtual key code for the ASCII "N" key.
VK_NONCONVERT
For Asian keyboards.
VK_NUM_LOCK
A virtual key code for the NUM LOCK key.
VK_NUMPAD0
A virtual key code for the numeric keypad "0" key.
VK_NUMPAD1
A virtual key code for the numeric keypad "1" key.
VK_NUMPAD2
A virtual key code for the numeric keypad "2" key.
VK_NUMPAD3
A virtual key code for the numeric keypad "3" key.
VK_NUMPAD4
A virtual key code for the numeric keypad "4" key.
VK_NUMPAD5
A virtual key code for the numeric keypad "5" key.
VK_NUMPAD6
A virtual key code for the numeric keypad "6" key.
VK_NUMPAD7
A virtual key code for the numeric keypad "7" key.
VK_NUMPAD8
A virtual key code for the numeric keypad "8" key.
VK_NUMPAD9
A virtual key code for the numeric keypad "9" key.
VK_O
A virtual key code for the ASCII "O" key.
VK_OPEN_BRACKET
A virtual key code for the OPEN BRACKET ([) key.
VK_P
A virtual key code for the ASCII "P" key.
VK_PAGE_DOWN
A virtual key code for the PAGE DOWN key.
VK_PAGE_UP
A virtual key code for the PAGE UP key.
VK_PAUSE
A virtual key code for the PAUSE (BREAK) key.
VK_PERIOD
A virtual key code for the PERIOD (.) key.
VK_PRINTSCREEN
A virtual key code for the PRINT SCREEN key.
VK_Q
A virtual key code for the ASCII "Q" key.
VK_QUOTE
A virtual key code for the QUOTATION MARK key.
VK_R
A virtual key code for the ASCII "R" key.
VK_RIGHT
A virtual key code for the RIGHT ARROW key.
VK_S
A virtual key code for the ASCII "S" key.
VK_SCROLL_LOCK
A virtual key code for the SCROLL LOCK key.
VK_SEMICOLON
A virtual key code for the SEMICOLON (;) key.
VK_SEPARATER
VK_SHIFT
A virtual key code for the SHIFT key.
VK_SLASH
A virtual key code for the forward slash (/) key.
VK_SPACE
A virtual key code for the SPACEBAR key.
VK_SUBTRACT
A virtual key code for the numeric keypad MINUS SIGN (-)
key.
VK_T
A virtual key code for the ASCII "T" key.
VK_TAB
A virtual key code for the TAB key.
VK_U
A virtual key code for the ASCII "U" key.
VK_UNDEFINED
KEY_TYPED events do not have a defined key code.
VK_UP
A virtual key code for the UP ARROW key.
VK_V
A virtual key code for the ASCII "V" key.
VK_W
A virtual key code for the ASCII "W" key.
VK_X
A virtual key code for the ASCII "X" key.
VK_Y
A virtual key code for the ASCII "Y" key.
VK_Z
A virtual key code for the ASCII "Z" key.

 
1、form上放一label,form的onkeydown事件写:
label1.Caption:=inttostr(key); //label显示的即为你刚按下的键值
2、mbLeft, mbRight, mbMiddle 分别表示左键、右键和中间键,在onmousedowan
事件的参数中进行相应设置就可以了

 
showmessage(inttostr(ord('r')));
 
后退
顶部