这里有段代码不知错在那里, 就是不能运行, 大虾帮手看看.
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
procedure WMHotKey(var Msg: TWMHotKey); message WM_HOTKEY;
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}var
HotKeyId: array[0..12] of Integer; //热键数组, 这里准备定义 13 个热键procedure TForm1.FormCreate(Sender: TObject);
var
i: Integer;
begin
//注册热键
for i := Low(HotKeyId) to High(HotKeyId) do
HotKeyId[i] := GlobalAddAtom(PChar(IntToStr(i))); //热键命名可随意
RegisterHotKey(Handle,HotKeyId[0],0,VK_F2); //F2
RegisterHotKey(Handle,HotKeyId[1],0,VK_UP); //Up
RegisterHotKey(Handle,HotKeyId[2],0,VK_DOWN); //Down
RegisterHotKey(Handle,HotKeyId[3],0,VK_LEFT); //Left
RegisterHotKey(Handle,HotKeyId[4],0,VK_RIGHT); //Right
RegisterHotKey(Handle,HotKeyId[5],0,VK_PRIOR); //PageUp
RegisterHotKey(Handle,HotKeyId[6],0,VK_NEXT); //PageDown
RegisterHotKey(Handle,HotKeyId[7],0,VK_OEM_PLUS); //+
RegisterHotKey(Handle,HotKeyId[8],0,VK_OEM_MINUS); //-
RegisterHotKey(Handle,HotKeyId[9],0,$31); //1
RegisterHotKey(Handle,HotKeyId[10],0,$41); //a
RegisterHotKey(Handle,HotKeyId[11],0,VK_RETURN); //Enter
RegisterHotKey(Handle,HotKeyId[12],MOD_CONTROL,VK_RETURN); //Ctrl+Enter
end;//热键
procedure TForm1.WMHotKey(var Msg: TWMHotKey);
begin
if Msg.HotKey = HotKeyId[0] then ShowMessage('F2');
if (Msg.HotKey=HotKeyId[1]) then ShowMessage('Up');
if (Msg.HotKey=HotKeyId[2]) then ShowMessage('Down');
if (Msg.HotKey=HotKeyId[3]) then ShowMessage('Left');
if (Msg.HotKey=HotKeyId[4]) then ShowMessage('Right');
if Msg.HotKey = HotKeyId[5] then ShowMessage('PageUp');
if Msg.HotKey = HotKeyId[6] then ShowMessage('PageDown');
if Msg.HotKey = HotKeyId[7] then ShowMessage('+');
if Msg.HotKey = HotKeyId[8] then ShowMessage('-');
if Msg.HotKey = HotKeyId[9] then ShowMessage('1');
if Msg.HotKey = HotKeyId[10] then ShowMessage('a');
if Msg.HotKey = HotKeyId[11] then ShowMessage('Enter');
if Msg.HotKey = HotKeyId[12] then ShowMessage('Ctrl+Enter');
end;procedure TForm1.FormDestroy(Sender: TObject);
var
i: Integer;
begin
//注销热键
for i := Low(HotKeyId) to High(HotKeyId) do
begin
UnRegisterHotKey(handle,HotKeyId[i]);
GlobalDeleteAtom(HotKeyId[i]);
end;
end;end.
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
procedure WMHotKey(var Msg: TWMHotKey); message WM_HOTKEY;
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}var
HotKeyId: array[0..12] of Integer; //热键数组, 这里准备定义 13 个热键procedure TForm1.FormCreate(Sender: TObject);
var
i: Integer;
begin
//注册热键
for i := Low(HotKeyId) to High(HotKeyId) do
HotKeyId[i] := GlobalAddAtom(PChar(IntToStr(i))); //热键命名可随意
RegisterHotKey(Handle,HotKeyId[0],0,VK_F2); //F2
RegisterHotKey(Handle,HotKeyId[1],0,VK_UP); //Up
RegisterHotKey(Handle,HotKeyId[2],0,VK_DOWN); //Down
RegisterHotKey(Handle,HotKeyId[3],0,VK_LEFT); //Left
RegisterHotKey(Handle,HotKeyId[4],0,VK_RIGHT); //Right
RegisterHotKey(Handle,HotKeyId[5],0,VK_PRIOR); //PageUp
RegisterHotKey(Handle,HotKeyId[6],0,VK_NEXT); //PageDown
RegisterHotKey(Handle,HotKeyId[7],0,VK_OEM_PLUS); //+
RegisterHotKey(Handle,HotKeyId[8],0,VK_OEM_MINUS); //-
RegisterHotKey(Handle,HotKeyId[9],0,$31); //1
RegisterHotKey(Handle,HotKeyId[10],0,$41); //a
RegisterHotKey(Handle,HotKeyId[11],0,VK_RETURN); //Enter
RegisterHotKey(Handle,HotKeyId[12],MOD_CONTROL,VK_RETURN); //Ctrl+Enter
end;//热键
procedure TForm1.WMHotKey(var Msg: TWMHotKey);
begin
if Msg.HotKey = HotKeyId[0] then ShowMessage('F2');
if (Msg.HotKey=HotKeyId[1]) then ShowMessage('Up');
if (Msg.HotKey=HotKeyId[2]) then ShowMessage('Down');
if (Msg.HotKey=HotKeyId[3]) then ShowMessage('Left');
if (Msg.HotKey=HotKeyId[4]) then ShowMessage('Right');
if Msg.HotKey = HotKeyId[5] then ShowMessage('PageUp');
if Msg.HotKey = HotKeyId[6] then ShowMessage('PageDown');
if Msg.HotKey = HotKeyId[7] then ShowMessage('+');
if Msg.HotKey = HotKeyId[8] then ShowMessage('-');
if Msg.HotKey = HotKeyId[9] then ShowMessage('1');
if Msg.HotKey = HotKeyId[10] then ShowMessage('a');
if Msg.HotKey = HotKeyId[11] then ShowMessage('Enter');
if Msg.HotKey = HotKeyId[12] then ShowMessage('Ctrl+Enter');
end;procedure TForm1.FormDestroy(Sender: TObject);
var
i: Integer;
begin
//注销热键
for i := Low(HotKeyId) to High(HotKeyId) do
begin
UnRegisterHotKey(handle,HotKeyId[i]);
GlobalDeleteAtom(HotKeyId[i]);
end;
end;end.
解决方案 »
- 请问怎么在程序里实现备份压缩一个数据库,然后解压恢复它,请给出例程,特别是解压恢复!!!!!
- ****高手请进:如何通过编程实现为XP系统下的一个文件夹添加用户,详情请进,问题解决立即给分****
- 请辞——Delphi 图形处理/多媒体 斑竹 @_@
- ora-12154 tns:无法处理服务名 是怎么回事啊
- COM问题
- 想认识几个Delphi朋友共同进步,来者有分!!!
- 给60分 !!个位!为什么开发串口通讯时用到的API结构DCB在DELPHI里少了很多的数据成员,我想控制RTS为高电平怎么控制阿?????
- 请问Assign是什么属性怎么应用的呢。
- 有谁在用delphi6,说说他有什么新特性好吗?
- 使用SQL语句出现"Invalid BLOB handle in record buf"是为什么?解决了一定给分!
- 从网上下载delphi源代码例子,经常会出现这个提示,怎么解决?
- 问个数据库问题
http://blog.csdn.net/yct0605/archive/2009/05/14/4182390.aspx
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
const
VK_OEM_PLUS:integer=187;
VK_OEM_MINUS:integer=189;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
procedure WMHotKey(var Msg: TWMHotKey); message WM_HOTKEY;
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}
var
HotKeyId: array[0..12] of Integer; //热键数组, 这里准备定义 13 个热键
procedure TForm1.FormCreate(Sender: TObject);
var
i: Integer;
begin
//注册热键
for i := Low(HotKeyId) to High(HotKeyId) do
HotKeyId[i] := GlobalAddAtom(PChar(IntToStr(i))); //热键命名可随意
RegisterHotKey(Handle,HotKeyId[0],0,VK_F2); //F2
RegisterHotKey(Handle,HotKeyId[1],0,VK_UP); //Up
RegisterHotKey(Handle,HotKeyId[2],0,VK_DOWN); //Down
RegisterHotKey(Handle,HotKeyId[3],0,VK_LEFT); //Left
RegisterHotKey(Handle,HotKeyId[4],0,VK_RIGHT); //Right
RegisterHotKey(Handle,HotKeyId[5],0,VK_PRIOR); //PageUp
RegisterHotKey(Handle,HotKeyId[6],0,VK_NEXT); //PageDown
RegisterHotKey(Handle,HotKeyId[7],0,VK_OEM_PLUS); //+
RegisterHotKey(Handle,HotKeyId[8],0,VK_OEM_MINUS); //-
RegisterHotKey(Handle,HotKeyId[9],0,$31); //1
RegisterHotKey(Handle,HotKeyId[10],0,$41); //a
RegisterHotKey(Handle,HotKeyId[11],0,VK_RETURN); //Enter
RegisterHotKey(Handle,HotKeyId[12],MOD_CONTROL,VK_RETURN); //Ctrl+Enter
end;//热键
procedure TForm1.WMHotKey(var Msg: TWMHotKey);
begin
if Msg.HotKey = HotKeyId[0] then ShowMessage('F2');
if (Msg.HotKey=HotKeyId[1]) then ShowMessage('Up');
if (Msg.HotKey=HotKeyId[2]) then ShowMessage('Down');
if (Msg.HotKey=HotKeyId[3]) then ShowMessage('Left');
if (Msg.HotKey=HotKeyId[4]) then ShowMessage('Right');
if Msg.HotKey = HotKeyId[5] then ShowMessage('PageUp');
if Msg.HotKey = HotKeyId[6] then ShowMessage('PageDown');
if Msg.HotKey = HotKeyId[7] then ShowMessage('+');
if Msg.HotKey = HotKeyId[8] then ShowMessage('-');
if Msg.HotKey = HotKeyId[9] then ShowMessage('1');
if Msg.HotKey = HotKeyId[10] then ShowMessage('a');
if Msg.HotKey = HotKeyId[11] then ShowMessage('Enter');
if Msg.HotKey = HotKeyId[12] then ShowMessage('Ctrl+Enter');
end;procedure TForm1.FormDestroy(Sender: TObject);
var
i: Integer;
begin
//注销热键
for i := Low(HotKeyId) to High(HotKeyId) do
begin
UnRegisterHotKey(handle,HotKeyId[i]);
GlobalDeleteAtom(HotKeyId[i]);
end;
end;
end.我这个测试过了,你的代码没有发全吧?
const
VK_OEM_PLUS:integer=187;
VK_OEM_MINUS:integer=189;
const
VK_OEM_PLUS:integer=187;
VK_OEM_MINUS:integer=189;