| 订阅 | 在线投稿
分享
 
 
 

DELPHI中使用热键

来源:互联网网民  宽屏版  评论
2006-09-16 05:50:28

本文为【DELPHI中使用热键】的汉字拼音对照版显示拼音

zaiwindowszhongguidingyingyongchengxurejiandeweiyibiaoshifuquzhifanweizai0x0000~0xBFFFzhijiandongtailianjiekudequzhifanweizai0xC000~0XFFFFzhijian

rejiandefuzhuanjianhuanbaokuoMod_Ctrl,Mod_AltheMod_ShiftduiyuwindowsjianrongjianpanhuanbaokuowindowsbiaozhijianMod_Win

rejianshezhichenggonghouzaichengxuyunxingguochengzhongruguoyouyudingyiderejianbeianxiawindowsxitongdouhuigeiyingyongchengxufasongyigewm_hotkeyxiaoxi

xiamianyongyigeliziyanshitade使shiyong

bianyichengxuyunxingruguocichengxubushidangqianzhuomianxianshizaizuiqianbiandechuangtianxiactrl+alt+ahouchengxujiemianjiangchuxianzaizhuomiandezuishang

shilichengxukaifapingtaiD7+WINXP

zhuanzaiqingzhumingchuchu

DELPHI中使用热键
unit Unit1;
DELPHI中使用热键

DELPHI中使用热键
interface
DELPHI中使用热键

DELPHI中使用热键
uses
DELPHI中使用热键
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
DELPHI中使用热键

DELPHI中使用热键
type
DELPHI中使用热键
TForm1 = class(TForm)
DELPHI中使用热键
procedure FormCreate(Sender: TObject);
DELPHI中使用热键
procedure FormClose(Sender: TObject; var Action: TCloseAction);
DELPHI中使用热键
private
DELPHI中使用热键
DELPHI中使用热键
...{ Private declarations }
DELPHI中使用热键
public
DELPHI中使用热键
DELPHI中使用热键
...{ Public declarations }
DELPHI中使用热键
hotkeyid :integer; //jilurejianbiaoshi
DELPHI中使用热键
//chuliwm_hotkeyxiaoxi
DELPHI中使用热键
procedure WMhotkeyhandle(var msg:Tmessage);
DELPHI中使用热键
message wm_hotkey;
DELPHI中使用热键

DELPHI中使用热键
end;
DELPHI中使用热键

DELPHI中使用热键
var
DELPHI中使用热键
Form1: TForm1;
DELPHI中使用热键

DELPHI中使用热键
implementation
DELPHI中使用热键

DELPHI中使用热键
DELPHI中使用热键
...{$R *.DFM}
DELPHI中使用热键
procedure TForm1.Wmhotkeyhandle
DELPHI中使用热键
(var msg:Tmessage);
DELPHI中使用热键
begin
DELPHI中使用热键
//panduanshifoushictrl+alt+a
DELPHI中使用热键
if (msg.LParamHi=$41) and
DELPHI中使用热键
(msg.lparamLo=MOD_CONTROL or mod_Alt) then
DELPHI中使用热键
begin
DELPHI中使用热键
msg.Result:=1;//zhengchangfanhui
DELPHI中使用热键
application.BringToFront;//jiangchuangtixianshizaizuiqianbian
DELPHI中使用热键
end;
DELPHI中使用热键
end;
DELPHI中使用热键

DELPHI中使用热键
procedure TForm1.FormCreate(Sender: TObject);
DELPHI中使用热键
begin
DELPHI中使用热键
//tongguoyuanzibiaohuodeyigeguanyuhotkeydeweiyibiaoshizhuyibenwenqianbiantidaodefanwei
DELPHI中使用热键
hotkeyid:=GlobalAddAtom(pchar('UserDefineHotKey'))-$C000;
DELPHI中使用热键
//zhucectrl+alt+a
DELPHI中使用热键
registerhotkey(handle,hotkeyid,MOD_CONTROL or mod_Alt,$41);
DELPHI中使用热键

DELPHI中使用热键
end;
DELPHI中使用热键

DELPHI中使用热键
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
DELPHI中使用热键
begin
DELPHI中使用热键
unregisterhotkey(handle,hotkeyid);//
DELPHI中使用热键
DeleteAtom(HotKeyID);
DELPHI中使用热键
end;
DELPHI中使用热键

DELPHI中使用热键
end.
DELPHI中使用热键

原文
 
特别声明:以上内容(如有图片或视频亦包括在内)为网络用户发布,本站仅提供信息存储服务。
 
在windows中规定应用程序热键的唯一标识符取值范围在0x0000~0xBFFF之间,动态链接库的取值范围在0xC000~0XFFFF之间。 热键的辅助按键还包括Mod_Ctrl,Mod_Alt和Mod_Shift,对于windows兼容键盘,还包括windows标志键,Mod_Win。 热键设置成功后,在程序运行过程中如果有预定义的热键被按下,windows系统都会给应用程序发送一个wm_hotkey消息。 下面用一个例子演示它的使用 编译程序、运行,如果此程序不是当前桌面显示在最前边的窗体,按下ctrl+alt+a后,程序界面将出现在桌面的最上。 示例程序开发平台:D7+WINXP 转载请注明出处。 [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]unit Unit1; [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]interface [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]uses [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs; [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]type [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] TForm1 = class(TForm) [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] procedure FormCreate(Sender: TObject); [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] procedure FormClose(Sender: TObject; var Action: TCloseAction); [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] private [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif[/img][/url][url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif[/img][/url] ...{ Private declarations } [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] public [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif[/img][/url][url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif[/img][/url] ...{ Public declarations } [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] hotkeyid :integer; //记录热键标识 [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] //处理wm_hotkey消息 [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] procedure WMhotkeyhandle(var msg:Tmessage); [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] message wm_hotkey; [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] end; [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]var [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] Form1: TForm1; [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]implementation [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif[/img][/url][url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif[/img][/url]...{$R *.DFM} [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]procedure TForm1.Wmhotkeyhandle [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url](var msg:Tmessage); [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]begin [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] //判断是否是ctrl+alt+a [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] if (msg.LParamHi=$41) and [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] (msg.lparamLo=MOD_CONTROL or mod_Alt) then [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] begin [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] msg.Result:=1;//正常返回 [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] application.BringToFront;//将窗体显示在最前边 [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] end; [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]end; [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]procedure TForm1.FormCreate(Sender: TObject); [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]begin [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] //通过原子表获得一个关于hotkey的唯一标识,注意本文前边提到的范围 [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] hotkeyid:=GlobalAddAtom(pchar('UserDefineHotKey'))-$C000; [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] //注册ctrl+alt+a [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] registerhotkey(handle,hotkeyid,MOD_CONTROL or mod_Alt,$41); [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]end; [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]begin [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] unregisterhotkey(handle,hotkeyid);// [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] DeleteAtom(HotKeyID); [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]end; [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url] [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]end. [url=http://www.wangchao.net.cn/bbs/hydetail_501490.html][img]http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif[/img][/url]
󰈣󰈤
 
 
 
>>返回首页<<
 
 热帖排行
 
 
 
静静地坐在废墟上,四周的荒凉一望无际,忽然觉得,凄凉也很美
©2005- 王朝网络 版权所有