onkeydown()中好象可以
if key=vk_up then
..............
if key=vk_down then
..............
if key=vk_up then
..............
if key=vk_down then
..............
解决方案 »
- 奥运会开始了,散点分
- 请教一个优秀可靠的字符串压缩解压算法
- 日期问题
- 一个关于读取字符串的问题,帮忙
- 小弟是Delphi的新手,想了解一些关于delphi API函数的东东,哪位大哥有delphi API函数的格式和功能简介的文档!
- 请帮助我一下,好吗?
- 在Win98工作站运行数据库应用程序时出现能力不支持的错误!
- 关于数据备份问题,大侠请进!
- 如何编程实现把一个表里面的一个字段的内容加载到combobox里面
- 求救啊!快啊!
- 计算字段中在calcfields中加入以下代码,为何计算字段在第一条记录无值。提示找不到ylbh1。第二条以后均有值,该段代码如何进行优化。
- 关于ADOQUERY的问题!关心一下把!
procedure TfmLine.MeNameKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (Key = VK_DOWN) then begin
Key := Word(#0);
PostMessage(GetParentForm(self).Handle,WM_NEXTDLGCTL, 0, 0);
end
else if Key = VK_UP then begin
Key := Word(#0);
PostMessage(GetParentForm(Self).Handle, WM_NEXTDLGCTL, 1, 0);
end
else inherited;
end;
Shift: TShiftState);
begin
if Key = Char(VK_UP) then
begin
Key := #0;
SendMessage(GetParentForm(Self).Handle, WM_NEXTDLGCTL, 1, 0);
end
if Key = Char(VK_DOWN) then
begin
Key := #0;
SendMessage(GetParentForm(self).Handle,WM_NEXTDLGCTL, 0, 0);
end;
end;
keypress是不能响应这两个键的!要用keydown事件
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=vk_down then //fomr1的keypreview必须设为true
begin
key:=0;
sendmessage(handle,WM_NEXTDLGCTL,0,0);
end;
if key=vk_up then
begin
key:=0;
sendmessage(handle,WM_NEXTDLGCTL,1,0);
end;
end;
代码已测试通过,希望能把分给我!!
而且,在keypress也没有什么不可以的,把他的ASC码取出不就可以了吗。
你的代码是对的,但是我觉得你的说法很有问题,请问这个方法是你首创的么?如果不是,那么你也是盗版,把你的代码改一改,也许更有效率
procedure TfmLine.MeNameKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (Key = VK_DOWN) then begin
Key := Word(#0);
//PostMessage(GetParentForm(self).Handle,WM_NEXTDLGCTL, 0, 0);
PostMessage(self.Handle,WM_NEXTDLGCTL, 0, 0);
end
else if Key = VK_UP then begin
Key := Word(#0);
//PostMessage(GetParentForm(Self).Handle, WM_NEXTDLGCTL, 1, 0);
PostMessage(self.Handle,WM_NEXTDLGCTL, 1, 0);
end;
//我觉得没什么必要
//else inherited;
end;to kofxdm
keypress中的确接收不到up和down两个键,不信你试试
Shift: TShiftState);
begin
if (Key=VK_RETURN) then
SelectNext((sender as TWinControl),true,true);
end;procedure TFUser.SetKey;
var
I : integer;
begin
for i := 1 to 11 do
begin
TDBEdit(FindComponent('DBEdit'+ inttostr(I))).OnKeyDown := EnterNext;
end; for i := 1 to 2 do
begin
TDBComboBox(FindComponent('DBComboBox'+ inttostr(I))).OnKeyDown := EnterNext;
end;
end;这样就可以了