我有一Radiobutton 想设置其快捷键为f5,要达到在任何状态下按F5都让RADIOBUTTON
获取焦点,急啊,各位大师帮我啊,最好是完整代码
获取焦点,急啊,各位大师帮我啊,最好是完整代码
解决方案 »
- GetProcAddress
- 为什么钩子对某些游戏不起作用
- 对于一个表多个操作如何解决?急急急急急急!!!
- 谁能帮我生成这样一个TreeView的例子?
- 高难问题:COM+的大系统架构问题;
- 请问在一个unit自义函数,在另一个unit里面才能调用它???
- 高分求救!!!QRREPORT中如何对每页的数据用SUMMARYBAND进行统计!最后再合计!!!急急
- 各位高手:请问如何才能得到一个文件的属性? 比如快捷方式的目标文件
- 有谁在?今晚9:00结此贴!
- 这里的高手们是不是问题太简单就不愿回答?(无内容)
- 能用delphi7开发B/S结构的程序吗?
- 哪位大侠有delphi下的代码自动提示工具,多谢
procedure TForm1.FormCreate(Sender: TObject);
begin
id:=GlobalAddAtom('MyHotkey');
id1:=GlobalAddAtom('MyHotkey1');
id2:=GlobalAddAtom('MyHotkey2');
RegisterHotKey(Handle, id, MOD_CONTROL, VK_F1);
RegisterHotKey(Handle, id1, MOD_CONTROL, VK_F2);
RegisterHotKey(Handle, id2, MOD_CONTROL, VK_F3);
end;procedure TForm1.FormDestroy(Sender: TObject);
begin
UnregisterHotKey(Handle,ID);
UnregisterHotKey(Handle,ID1);
UnregisterHotKey(Handle,ID2);
end;procedure TForm1.WMHotKey(var Msg: TWMHotKey);
begin
if msg.HotKey=ID then
ShowMessage('Ctrl+F1!')
else if Msg.HotKey=ID1 then
ShowMessage('Ctrl+F2!')
else if Msg.HotKey=ID2 then
ShowMessage('Ctrl+F3!');
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
id:=GlobalAddAtom('112'); //a r 键值
id1:=GlobalAddAtom('113');
id2:=GlobalAddAtom('114');
RegisterHotKey(Handle, id, MOD_CONTROL, VK_F1);
RegisterHotKey(Handle, id1, MOD_CONTROL, VK_F2);
RegisterHotKey(Handle, id2, MOD_CONTROL, VK_F3);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
UnregisterHotKey(Handle,ID);
UnregisterHotKey(Handle,ID1);
UnregisterHotKey(Handle,ID2);
end;
procedure TForm1.WMHotKey(var Msg: TWMHotKey);
begin
if msg.HotKey=ID then
button1.SetFocus
else if Msg.HotKey=ID1 then
edit1.SetFocus
else if Msg.HotKey=ID2 then
edit1.SetFocus;
end;
begin
RadioGroup1.SetFocus ;
Handled := True ;
end ; //of if
1、将Form的Keypreview设置成True
2、在Form的Onkeydown事件中编写如下代码:
if key=vk_F5 then
radiobutton1.setfocus;
BOOL RegisterHotKey(
HWND hWnd, // window to receive hot-key notification
int id, // identifier of hot key
UINT fsModifiers, // key-modifier flags
UINT vk // virtual-key code);
参数 id为你自己定义的一个ID值,对一个线程来讲其值必需在0x0000 - 0xBFFF范围之内,对DLL来讲其值必需在0xC000 - 0xFFFF 范围之内,在同一进程内该值必须唯一
参数 fsModifiers指明与热键联合使用按键,可取值为:MOD_ALT MOD_CONTROL MOD_WIN MOD_SHIFT
参数 vk指明热键的虚拟键码
首先(举个例子):
RegisterHotKey(handle,globaladdatom('hot key'),MOD_ALT,vk_f12);
然后在form中声明一个函数(过程):
procedure hotkey(var msg:tmessage);message wm_hotkey;
过程如下:
procedure TForm1.hotkey(var msg:tmessage);
begin
if (msg.LParamHi=VK_F12) and (msg.LParamLo=MOD_ALT) then
begin
form1.show;
SetForegroundWindow(handle);
end;
end;
这样,不管你在什么地方,窗口就会显示出来。
当然,你要GlobalDeleteAtom;unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
aatom:atom;
procedure hotkey(var msg:tmessage);message wm_hotkey;
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}procedure TForm1.FormCreate(Sender: TObject);
begin
aatom:=globaladdatom('hot key');
RegisterHotKey(handle,aatom,MOD_ALT,vk_f12);
end;procedure TForm1.hotkey(var msg:tmessage);
begin
if (msg.LParamHi=VK_F12) and (msg.LParamLo=MOD_ALT) then
SetForegroundWindow(handle);
end; procedure TForm1.FormDestroy(Sender: TObject);
begin
globalDeleteatom(aatom);
end;end.
http://expert.csdn.net/Expert/topic/1376/1376141.xml?temp=.105221