中国IT动力,最新最全的IT技术教程
最新100篇 | 推荐100篇 | 专题100篇 | 排行榜 | 搜索 | 在线API文档 | 网通镜像
首 页 | 程序开发 | 操作系统 | 软件应用 | 图形图象 | 网络应用 | 精文荟萃 | 教育认证 | 硬件维护 | 未整理篇 | 站长教程
ASP JS PHP工程 ASP.NET 网站建设 UML J2EESUN .NET VC VB VFP 网络维护 数据库 DB2 SQL2000 Oracle Mysql
服务器 Win2000 Office C DreamWeaver FireWorks Flash PhotoShop 上网宝典 CorelDraw 协议大全 网络安全 微软认证
硬件维护  CPU  主板  硬盘  内存  显卡  显示器  键盘鼠标  声卡音箱  打印机  机箱电源  BIOS  网卡  C#  Java  Delphi  vs.net2005
  当前位置:> 程序开发 > 编程语言 > Delphi > 综合文章
如何改变Delphi的快捷键
作者:未知 时间:2005-08-07 21:01 出处:编程爱好者网站 责编:chinaitpower
              摘要:如何改变Delphi的快捷键
    如果说Delphi的IDE有什么优势的话,那么我想就是它本身就是由Delphi编写而成,因此我们能定制Delphi的IDE环境,通过Delphi的ToolsAPI的Com接口。

    下面这个例子使用IOTAKeyboardBinding接口,实现对快捷键的重新绑定,相关的接口定义见ToolsAPI.pas。源码很简单,相信你一看就懂。该例子用来修改与中文环境冲突的Code Completion得快捷键,改成Ctrl+Alt+Shift+P和Ctrl+Alt+Shift+O,如果你遇上什么问题,请写信给我。

//EagleBufferList.pas,2002.5.24

{
Pan Ying,Zero Studio
All Right Reserved.

The Demo show how to change Delphi's Key Binding,just in Delphi
press Ctrl+Alt+Shift+P to use Code Completion.You can contact me by
sending e-mail to me (panying@sina.com)

Some code from Delphi's ToolsAPI Demo.

Attention:
This software is provided 'as-is', without any express or
implied warranty. In no event will the author be held liable
for any damages arising from the use of this software.

This unit is free to use but the origin of this software
must not be misrepresented, you must not claim that you
wrote the original software.

Feel free to use this component in your product including
commercial applications.

If You alert this component's code to make it better,
please remember to tell me about it , let's to make it better
together.

This attention may not be removed or altered from any source
distribution.

Feedback:
E-Mail: panying@sina.com
HomePage:http://myzeroworld.yeah.net

Version 1.1
Remove some useless code.
Version 1.0
Initial Version.
}

unit EagleBufferList;

interface

procedure Register;

implementation

uses Windows, Classes, SysUtils,Menus, ToolsAPI, Controls ;

type
  TBufferList = class(TNotifierObject, IUnknown, IOTANotifier,
    IOTAKeyboardBinding)     
    function GetBindingType: TBindingType;
    function GetDisplayName: string;
    function GetName: string;
    procedure BindKeyboard(const BindingServices: IOTAKeyBindingServices);
  protected     
    procedure CodeCompletion(const Context: IOTAKeyContext; KeyCode: TShortcut;
      var BindingResult: TKeyBindingResult);
  end;
   
resourcestring
  sBufferList = 'Eagle''s Buffer List';   

//register this key binding
procedure Register;
begin
  (BorlandIDEServices as IOTAKeyBoardServices).AddKeyboardBinding(TBufferList.Create);   
end;

{ TBufferList }


//the code to bind key
procedure TBufferList.BindKeyboard(const BindingServices: IOTAKeyBindingServices);
begin
  BindingServices.AddKeyBinding([ShortCut(Ord('P'), [ssShift, ssCtrl, ssAlt])], CodeCompletion, Pointer(csCodeList or csManual));
  BindingServices.AddKeyBinding([ShortCut(Ord('O'), [ssShift, ssCtrl, ssAlt])], CodeCompletion, Pointer(csParamList or csManual));   
end;

//do code completion
procedure TBufferList.CodeCompletion(const Context: IOTAKeyContext;
  KeyCode: TShortcut; var BindingResult: TKeyBindingResult);
begin

  (Context.EditBuffer.TopView as IOTAEditActions).CodeCompletion(Byte(Context.Context));
  BindingResult := krHandled;

end;

function TBufferList.GetBindingType: TBindingType;
begin
  Result := btPartial;
end;

function TBufferList.GetDisplayName: string;
begin
  Result := sBufferList;
end;

function TBufferList.GetName: string;
begin
  Result := 'EagleKing.BufferList';  //do not localize
end;

end.

    如果你对组件或者向导编写感兴趣,到CNPack( http://cnpack.yeah.net )来看看。

Pan Ying,2002.5.25
零点天地(转载请保留此链接)

关闭本页
 
首页 | 投资与合作 | 服务条款 | 隐私政策 | 收藏本站 | 设为首页 | 新用户注册 | 免责声明 | 使用帮助
Copyright ©2005-2008 chinaitpower.com All rights reserved. www.chinaitpower.com 版权所有