问题描述:
delphi中想设置CTRL+ENTER引发一个事件,该怎么写
解析:
unit Unit1
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject)
procedure FormDestroy(Sender: TObject)
protected
procedure hotykey(var msg:TMessage)message WM_HOTKEY
end
var
Form1: TForm1
HotKey:Integer
implementation
{$R *.DFM}
procedure TForm1.hotykey(var msg:TMessage)
begin
if (msg.LParamLo=MOD_CONTROL) and (msg.LParamHi=13) then
begin
ShowMessage('你按了ctrl+enter')
end
end
procedure TForm1.FormCreate(Sender: TObject)
begin
HotKey:=GlobalAddAtom('HotKey')
RegisterHotKey(handle,HotKey,mod_control,13)
end
procedure TForm1.FormDestroy(Sender: TObject)
begin
UnRegisterHotKey(handle,HotKey)
end
end.
procedure TForm1.FormKeyDown(Sender: TObjectvar Key: WordShift: TShiftState)
begin
// ShowMessage(IntToStr(Key))
if (ssCtrl in Shift) and (Key = 66) then
begin
ShowMessage('你按下了Ctrl + B ')
end
end把Form的KeyPreView属性改为True 。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)