CnPack Forum


 
Subject: 一段IDE扩展代码在Delphi2009和D7中的不同表现
chenxinyu
新警察
Rank: 1



UID 21861
Digest Posts 0
Credits 24
Posts 8
点点分 24
Reading Access 10
Registered 2007-8-1
Status Offline
Post at 2009-2-19 14:59  Profile | Blog | P.M. 
一段IDE扩展代码在Delphi2009和D7中的不同表现

以下代码在IDE中注册一个热键Ctrl+H,当点击此热键时,弹出信息提示窗口,在D7和Delphi2009中均可以弹出提示窗口,但是在Delphi2009中,在关闭弹出窗口后,会发现在当前光标位置多了一个字符h,呵呵。。。

unit UnitCodeHelper;

interface

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

procedure Register;

implementation

type
  TCodeHelper = class(TNotifierObject, IOTAKeyboardBinding)
  private
  public
    function GetBindingType: TBindingType;
    function GetDisplayName: string;
    function GetName: string;
    procedure BindKeyboard(const BindingServices: IOTAKeyBindingServices);
    procedure CodeHelp(const Context: IOTAKeyContext; KeyCode: TShortcut; var BindingResult: TKeyBindingResult);
  end;

procedure Register;
begin
  (BorlandIDEServices as IOTAKeyBoardServices).AddKeyboardBinding(TCodeHelper.Create);
end;

procedure TCodeHelper.BindKeyboard(const BindingServices: IOTAKeyBindingServices);
begin
  BindingServices.AddKeyBinding([TextToShortCut('Ctrl+H')], CodeHelp, nil);
end;

procedure TCodeHelper.CodeHelp(const Context: IOTAKeyContext; KeyCode: TShortcut; var BindingResult: TKeyBindingResult);
var
  i, CurrentCol, BeginCol, CurrentRow, CurrentTopRow: integer;
  SearchKeyString: string;
begin
  showmessage('代码助手');
end;

function TCodeHelper.GetBindingType: TBindingType;
begin
  result := btPartial;
end;
                                                               h
function TCodeHelper.GetDisplayName: string;
begin
  result := '代码助手';
end;

function TCodeHelper.GetName: string;
begin
  result := 'CodeHelper';
end;

end.
Top
 




All times are GMT++8, the time now is 2024-9-17 03:23

    本论坛支付平台由支付宝提供
携手打造安全诚信的交易社区 Powered by Discuz! 5.0.0  © 2001-2006 Comsenz Inc.
Processed in 0.008441 second(s), 7 queries , Gzip enabled

Clear Cookies - Contact Us - CnPack Website - Archiver - WAP