在onkeypress事件中判断呀 if key=char(#13) then....//好久不用D了,可能写的不对,你测试一下
如果要在任何时候判断,那就是给窗体设置快劫键了,参考我的旧东西 例子中响应的是ctrl+alt+shift+F11和F7 private { Private declarations } aatom:atom; aatom2:atom; procedure hotkey(var msg:tmessage);message wm_hotkey; 。 。 。在form.create事件中写 //注册热键 aatom:=globaladdatom('hot key'); aatom2:=globaladdatom('hot key2'); RegisterHotKey(handle,aatom,mod_control+MOD_ALT+mod_shift,vk_f12); RegisterHotKey(handle,aatom2,mod_control+MOD_ALT+mod_shift,vk_f7);响应事件 procedure TForm1.hotkey(var msg:tmessage); begin if (msg.LParamHi=VK_F12) and (msg.LParamLo=mod_control+MOD_ALT+mod_shift) then if panel1.Visible then begin panel1.Visible:=false; end else begin panel1.Visible:=true; end; if (msg.LParamHi=VK_F7) and (msg.LParamLo=mod_control+MOD_ALT+mod_shift) then
if tabsheet4.Showing then begin tabsheet1.Show; end else begin tabsheet4.Show; end; end;
if key=char(#13) then....//好久不用D了,可能写的不对,你测试一下
例子中响应的是ctrl+alt+shift+F11和F7
private
{ Private declarations }
aatom:atom;
aatom2:atom;
procedure hotkey(var msg:tmessage);message wm_hotkey;
。
。
。在form.create事件中写
//注册热键
aatom:=globaladdatom('hot key');
aatom2:=globaladdatom('hot key2');
RegisterHotKey(handle,aatom,mod_control+MOD_ALT+mod_shift,vk_f12);
RegisterHotKey(handle,aatom2,mod_control+MOD_ALT+mod_shift,vk_f7);响应事件
procedure TForm1.hotkey(var msg:tmessage);
begin
if (msg.LParamHi=VK_F12) and (msg.LParamLo=mod_control+MOD_ALT+mod_shift) then
if panel1.Visible then
begin
panel1.Visible:=false;
end
else
begin
panel1.Visible:=true;
end; if (msg.LParamHi=VK_F7) and (msg.LParamLo=mod_control+MOD_ALT+mod_shift) then
if tabsheet4.Showing then
begin
tabsheet1.Show;
end
else
begin
tabsheet4.Show;
end;
end;
button1Click(application);烦请高手再指点一下,小弟不胜感激!
if key=chr(vk_return) then button1.Click;