Board logo

Subject: 一段IDE扩展代码在Delphi2009和D7中的不同表现 [Print This Page]

Author: chenxinyu    Time: 2009-2-19 14:59     Subject: 一段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.




Welcome to CnPack Forum (http://bbs.cnpack.org/) Powered by Discuz! 5.0.0