delphi中想设置CTRL+ENTER快捷键

delphi中想设置CTRL+ENTER快捷键,第1张

分类: 电脑/网络 >>程序设计 >>其他编程语言

问题描述:

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: Word

Shift: TShiftState)

begin

// ShowMessage(IntToStr(Key))

if (ssCtrl in Shift) and (Key = 66) then

begin

ShowMessage('你按下了Ctrl + B ')

end

end把Form的KeyPreView属性改为True 。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/11549295.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-16
下一篇 2023-05-16

发表评论

登录后才能评论

评论列表(0条)

保存