X xygz Unregistered / Unconfirmed GUEST, unregistred user! 2001-06-13 #3 将FORM的KEYPREVIEW设为TRUE,然后在UNKEYDOWN/ONKEYPRESS事件里判断KEY的值就 可以了啊
B bbkxjy Unregistered / Unconfirmed GUEST, unregistred user! 2001-06-13 #4 怎么不先查找一下,太多了... procedure TForm1.OnKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin case Key of VK_UP:...; VK_DOWN:...; VK_LEFT:...; VK_RIGHT:...; else ... end; end;
怎么不先查找一下,太多了... procedure TForm1.OnKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin case Key of VK_UP:...; VK_DOWN:...; VK_LEFT:...; VK_RIGHT:...; else ... end; end;
F ft28 Unregistered / Unconfirmed GUEST, unregistred user! 2001-06-14 #7 各位要注意: 方向键和tab键不产生onkeydown 事件。没有那么简单。
B bbkxjy Unregistered / Unconfirmed GUEST, unregistred user! 2001-06-14 #8 to ft28: 对于form,是不产生的。可以这样: type TForm1 = class(TForm) private ... procedure CMDialogKey(var Msg: TCMDialogKey); message CM_DIALOGKEY; ... end; implememtation ... procedure TForm1.CMDialogKey(var Msg: TCMDialogKey); var ShiftState: TShiftState; begin ShiftState := KeyDataToShiftState(Msg.KeyData); case Msg.CharCode of VK_TAB: VK_UP:...; VK_DOWN:...; VK_LEFT:...; VK_RIGHT:...; else ... end; inherited;//要调用缺省的处理 end;
to ft28: 对于form,是不产生的。可以这样: type TForm1 = class(TForm) private ... procedure CMDialogKey(var Msg: TCMDialogKey); message CM_DIALOGKEY; ... end; implememtation ... procedure TForm1.CMDialogKey(var Msg: TCMDialogKey); var ShiftState: TShiftState; begin ShiftState := KeyDataToShiftState(Msg.KeyData); case Msg.CharCode of VK_TAB: VK_UP:...; VK_DOWN:...; VK_LEFT:...; VK_RIGHT:...; else ... end; inherited;//要调用缺省的处理 end;
J jinrui Unregistered / Unconfirmed GUEST, unregistred user! 2001-06-14 #9 procedure TForm1.OnKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin case Key of 37 //(38,39,40) else ... end; end;
procedure TForm1.OnKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin case Key of 37 //(38,39,40) else ... end; end;
S sjt Unregistered / Unconfirmed GUEST, unregistred user! 2001-06-14 #11 to xygz 不需要将FORM的KEYPREVIEW设为TRUE,就咳在UNKEYDOWN/ONKEYPRESS事件里判断KEY的值
L lww Unregistered / Unconfirmed GUEST, unregistred user! 2001-06-16 #12 学习一下用钩子吧,处理这类问题的首选,DFW里面已经有很多相应的答案, 比如:LID:495775 或者可以按键盘钩子关键字进行查找,大把的例子。