ShortCutToText , TextToShortCut 需 uses Menus;

type
TForm1 = class(TForm)
HotKey1: THotKey;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
procedure WMHotKey(var Msg:TMessage);message WM_HOTKEY;
public
{ Public declarations }
end; var
Form1: TForm1; implementation {$R *.dfm} var
Key, Shift: Word;
Id: Integer; procedure ShortCutToKey(ShortCut: TShortCut; var Key: Word; var Shift: TShiftState);
begin
Key := ShortCut and not (scShift + scCtrl + scAlt);
Shift := [];
if ShortCut and scShift <> 0 then Include(Shift, ssShift);
if ShortCut and scCtrl <> 0 then Include(Shift, ssCtrl);
if ShortCut and scAlt <> 0 then Include(Shift, ssAlt);
end; function ShiftStateToWord(TShift: TShiftState): Word;
begin
Result := 0;
if ssShift in TShift then Result := MOD_SHIFT;
if ssCtrl in TShift then Result := Result or MOD_CONTROL;
if ssAlt in TShift then Result:= Result or MOD_ALT;
end; procedure TForm1.Button1Click(Sender: TObject);
var
T: TShiftState;
begin
Id := GlobalAddAtom('MyHotKey') - $C000;
ShortCutToKey(HotKey1.HotKey, Key, T);
Shift := ShiftStateToWord(T);
RegisterHotKey(Handle, Id, Shift, Key);
end; procedure TForm1.WMHotKey(var Msg: TMessage);
begin
if (Msg.LparamLo = Shift) AND (Msg.LParamHi = Key) then
ShowMessage('This is HotKey');
end; procedure TForm1.FormDestroy(Sender: TObject);
begin
UnRegisterHotKey(Handle, Id);
GlobalDeleteAtom(Id);
end; end.

【Delphi】注册快捷键的更多相关文章

  1. listbox鼠标拖动数据和为button注册快捷键

    将listbox1中的数据用鼠标拖动至listbox2,即有左至右. 分别对应控件注册如下事件DragEnter,MouseDown,DragDrop 代码如下: //P128 DataGridVie ...

  2. 【转】C#注册快捷键

    转自:http://blog.csdn.net/xiahn1a/article/details/42561015 这里需要引用到“user32.dll”.对于Win32的API,调用起来还是需要dll ...

  3. Delphi常用快捷键

    delphi是我学编程时的入门语言,用过一年多的时光,个人对它还是挺喜欢的.现在用的少了,一些快捷键和语法也有些遗忘了,这里对delphi的快捷键做个总结,留个纪念.嘿嘿,不知道还有多少人还用着这门语 ...

  4. delphi 注册表操作(读取、添加、删除、修改)完全手册

    DELPHI VS PASCAL(87)  32位Delphi程序中可利用TRegistry对象来存取注册表文件中的信息. 一.创建和释放TRegistry对象 1.创建TRegistry对象.为了操 ...

  5. 教程-Delphi操作快捷键

    ************************************************************** Delphi快捷键-全-高手用-南山古桃(新手)-同学共进 ******* ...

  6. Delphi中快捷键的使用

    CTRL+SHIFT+↑(↓) 在过程.函数.事件内部, 可跳跃到相应的过程.函数.事件的定义(在INTERFACE和IMPLEMENTATION之间来回切换)CTRL+J (弹出DELPHI语句提示 ...

  7. delphi 注册表

    Delphi中定义了一个Tregistry类,通过使用这个类中封装的很多有关对注册表操作的方法和属性可以完成对注册表的操作.1. 在注册表中创建一个新的关键字Tregistry类中有一个CreateK ...

  8. Delphi 注册文件类型 设置文件图标

        {------------------------------------------------------------------------------- @过程名: slpert -& ...

  9. delphi 注册 dcc70.dll

    @echo 开始注册copy dcc70.dll %windir%\system32\regsvr32 %windir%\system32\dcc70.dll /s@echo dcc70.dll注册成 ...

随机推荐

  1. java cmd 命令

    java的Runtime.getRuntime().exec(commandStr)可以调用执行cmd指令. cmd /c dir 是执行完dir命令后关闭命令窗口. cmd /k dir 是执行完d ...

  2. MapHttpRoute

    http://aspnetwebstack.codeplex.com/SourceControl/latest#src/System.Web.Http/HttpRouteCollectionExten ...

  3. zsh配置文件

    zsh通过编辑~/.zshrc来配置环境变量,bash通过编辑~/.bash_profile来做同样的事

  4. 海外支付:抵御信用卡欺诈的CyberSource

    海外支付:抵御信用卡欺诈的CyberSource 吴剑 2014-06-04 原创文章,转载必需注明出处:http://www.cnblogs.com/wu-jian 吴剑 http://www.cn ...

  5. VS error retrieving information from user datastore

    搭建好VS2005+PB6.0的开发环境后,新建MFC智能设备应用程序工程出错,错误信息如下: error retrieving information from user datastore 很奇怪 ...

  6. 【HTTP】POST 与 PUT 方法区别

    1. POST 用于向服务端发送数据,常用于表单数据提交: PUT   用于向服务器上的资源(如文件)中存储数据: 2. 302 303 307 状态码区别 他们都是重定向(临时重定向 p.s 301 ...

  7. SICP 换零钱的迭代版本

    看到换零钱方式统计这里, 书中给出了递归的实现但没有给出迭代版本说要留给读者作为挑战, 既然说是作为挑战那肯定是能解决的,在想了一天无果之后最终在别人博客的帮助下终于实现了迭代的版本...也算是经历坎 ...

  8. Android开发-API指南-数据存储

    Storage Options 英文原文:http://developer.android.com/guide/topics/data/data-storage.html 采集日期:2015-02-0 ...

  9. flex使用buttonbar为viewstack添加导航功能

    先建立一个Main.mxml的应用程序,作为一个主程序,再建立两个component ,一个是jiaju.mxml ,另一个是dianqi.mxml. Main.mxml:  <?xml ver ...

  10. Flex应用一览表

    1.Flex控件之repeater和radioButton控件应用 2.Flex之DataGrid和Tree控件的数据源XML格式  3.Flex控件之combobox应用 4.转:Flex的Arra ...