procedure WMKEYDOWN(var Msg: TWMKEYDOWN); message WM_KEYDOWN;
begin
if Msg.CharCode = VK_SHIFT then
begin
如何判断是按下了Shift和方向键
end
else if Msg.CharCode = VK_Delete then
begin
end;
end;
我想实现像delphi设计时一样按下Shift和方向键就移动控件的坐标,就申明了上面的
消息处理过程,是判断 Msg结构中的什么成员才能知道是同时按下了Shift和方向键,
谢谢各位!!!!
begin
if Msg.CharCode = VK_SHIFT then
begin
如何判断是按下了Shift和方向键
end
else if Msg.CharCode = VK_Delete then
begin
end;
end;
我想实现像delphi设计时一样按下Shift和方向键就移动控件的坐标,就申明了上面的
消息处理过程,是判断 Msg结构中的什么成员才能知道是同时按下了Shift和方向键,
谢谢各位!!!!
解决方案 »
- 请解释下这两种定义,有什么区别,看不懂
- rpc服务器不可用!
- 紧急求救一sql语句,谢谢啦
- 如何增加数据时不会立刻写入数据库中,而是调用POST方法后才写入呢
- 终于考完了执业医师考试,又可以天天上CSDN了,散分!!!
- 批处理重命名
- 关于循环引用
- TO: COM+专家在哪里?请帮我看一下这个问题... ... http://www.csdn.net/expert/topicview1.asp
- 怎样将String转换为PChar?谢谢!(在使用SendMessage)
- 问个非技术问题,有谁知道?
- 一个有关WebServer Application 的问题?
- 在三层中怎么知道有多少CLIENT连上了SERVER?
shift本身就会触发wm_keydown事件
if (Key = VK_UP) and (ssShift in Shift) then
// do your things
GetAsyncKeyState(VK_LEFT)<0 //按下了左键头键
GetAsyncKeyState(VK_RIGHT)<0 //按下了右键头键
GetAsyncKeyState(VK_UP)<0 //按下了上键头键
GetAsyncKeyState(VK_DOWN)<0 //按下了下键头键GetKeyState 和 GetAsyncKeyState 的区别:
GetKeyState: 从缓冲区取键的状态。比如按下Shift键之后,进入调试 状态,
松开了Shift键,此时得到的GetKeyState(VK_SHIFT)<0
GetAsyncKeyState:判断当前的键的状态。比如按下Shift键之后,进入调试状态,
松开了Shift键,此时得到的GetKeyState(VK_SHIFT)>=0
ctrl_A = 1; { ASCII value for Ctrl+A }
ctrl_Z = 26; { ASCII value for Ctrl+Z } FunctionKeys: array [vk_f1 .. vk_f12] of string[3] =
('F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8',
'F9', 'F10', 'F11', 'F12');procedure TMainForm.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
var
s: string;
begin
EditValue.Text:= IntToStr(Key);
s := '';
if ssShift in Shift then
s := s + 'Shift+';
if ssAlt in Shift then
s := s + 'Alt+';
if ssCtrl in Shift then
s := s + 'Ctrl+';
if Length(s) > 0 then
Delete(s, Length(s), 1);
EditShift.Text := s;
if Key in [vk_f1 .. vk_f12] then
EditChar.Text := FunctionKeys[Key]
else
EditChar.Text := '';
if Key = vk_space then
Key := 0;
end;procedure TMainForm.FormKeyPress(Sender: TObject; var Key: Char);
begin
if Ord(Key) in [ctrl_A .. ctrl_Z] then
EditChar.Text := '^' + Chr(Ord(Key) + Ord('A') - 1)
else
EditChar.Text := Key;
EditValue.Text := IntToStr(Ord(Key));
end;procedure TMainForm.FormKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
EditChar.Text := '';
EditValue.Text := '';
EditShift.Text := '';
end;procedure TMainForm.ButtonExitClick(Sender: TObject);
begin
Application.Terminate;
end;