使用Delphi Open Tools API将我自己的项目添加到Delphi IDE Insight(F6)中 [英] Add my own items to Delphi IDE Insight (F6) with in Delphi Open Tools API

查看:132
本文介绍了使用Delphi Open Tools API将我自己的项目添加到Delphi IDE Insight(F6)中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用INTAIDEINsightServiceAddItemAddActionList为Delphi中的IDE洞察功能添加一个条目.

I want to use INTAIDEINsightService perhaps AddItem or AddActionList to add an entry to the IDE insight feature in Delphi.

根据Delphi OTA Wiki,INTAIDEINsightService允许您注册自己的操作.我唯一可以找到的参考文献是此处,其中提到了API的名称,并且该名称完全存在​​. Delphi帮助中没有关于它的任何内容. Delphi XE中的ToolsAPI.pas单元在此界面中显示了两种方法,可让您注册操作:

According to the Delphi OTA wiki, INTAIDEINsightService allows you to register your own action. The only reference I can find is here, which mentions the name of the API, and that it exists at all. There is nothing in the Delphi help about it. The ToolsAPI.pas unit in Delphi XE shows two methods in this interface that let you register actions:

function AddActionList(  Actions: TCustomActionList; ... ): Integer;
procedure RemoveActionList(const Index: Integer);

评论说:项目将显示为[Description |] Category | TCustomAction.Caption.包含的未指定类别的动作将不会显示."

The comments say "Items will be shown as[Description |] Category | TCustomAction.Caption. Contained actions which do not specify a category will not be shown.".

我无法使用操作找到任何其他文档或样本.一个简单的"hello world"示例,其中将一个动作或仅一个项目注册为描述或类别"helloworld",然后可以进行搜索并在您按下F6时显示出来,这是完美的选择,但是Actions是首选.

I haven't been able to find any other documentation or samples using actions. A simple "hello world" example where an action, or just an item, is registered with description or category "helloworld", that is then searchable and shows up when you hit F6 would be perfect, but Actions are preferred.

看起来这样的向导必须实现INTAIDEInsightItem才能在IDE洞察中呈现自己,但是我不确定是否必需"用于hello-world示例.我不确定是否需要使用操作,或者常规的项目"添加是否足够.

It looks like such a wizard would have to implement INTAIDEInsightItem in order to render itself inside the IDE insight, but I'm not sure if that's "required" for a hello-world sample or not. I'm not really sure if you have to use actions, or if regular "item" adds are sufficient.

(我的最终目标是创建一个新的gExperts风格的专家,以通过使用IDE见解按名称搜索在我的库路径中打开任何单元",但我首先将单元名添加到ide见解中一次.)

(My ultimate goal is to create a new gExperts-style expert to "open any unit in my library path by searching for it by name using IDE insight" but I'll start with adding unit names to the ide insight one item at a time.)

推荐答案

下面显示了命令"下的类别你好":

The following shows category 'Hello' under 'Commands':

unit Unit1;

interface

uses
  SysUtils, Classes, ActnList, ImgList, Controls;

type
  TDataModule1 = class(TDataModule)
    ActionList1: TActionList;
    ImageList1: TImageList;
    ActionHello: TAction;
    procedure ActionHelloExecute(Sender: TObject);
  private
  public
  end;

var
  DataModule1: TDataModule1;

implementation

{$R *.dfm}

uses
  ToolsAPI, Dialogs;

procedure TDataModule1.ActionHelloExecute(Sender: TObject);
begin
  ShowMessage('Hello, world!');
end;

var
  Index: Integer = -1;

initialization
  DataModule1 := TDataModule1.Create(nil);
  Index := (BorlandIDEServices as INTAIDEInsightService).AddActionList(DataModule1.ActionList1);

finalization
  if Index <> -1 then
    (BorlandIDEServices as INTAIDEInsightService).RemoveActionList(Index);
  FreeAndNil(DataModule1);

end.

dfm只是一个带有动作列表,图像列表和动作的数据模块:

The dfm is simply a datamodule with an action list, image list and an action:

object DataModule1: TDataModule1
  OldCreateOrder = False
  Left = 218
  Top = 134
  Height = 215
  Width = 306
  object ActionList1: TActionList
    Images = ImageList1
    Left = 24
    Top = 16
    object ActionHello: TAction
      Category = 'Hello'
      Caption = 'Hello, World!'
      ImageIndex = 0
      OnExecute = ActionHelloExecute
    end
  end
  object ImageList1: TImageList
    Left = 88
    Top = 16
    Bitmap = {
      494C010101000C000C0010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
      0000000000003600000028000000400000001000000001002000000000000010
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000800080008000800086868600000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000008000800080008000FFFFFF00FFFFFF00C0C0C000868686000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000008000
      800080008000FFFFFF00FFFFFF000000000000000000C0C0C000C0C0C0008686
      8600000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      000000000000000000000000000000000000868686008000800080008000FFFF
      FF00FFFFFF000000000000000000800080008000800000000000C0C0C000C0C0
      C000868686000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000008686860080008000FFFFFF000000
      000000000000800080008000800080008000800080008000800000000000C0C0
      C000C0C0C0008686860000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000008686860000000000000000008000
      800080008000800080000080800000FFFF008000800080008000800080000000
      0000C0C0C000C0C0C00086868600000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000008686860080008000800080008000
      8000800080008000800080008000008080008000800080008000800080008000
      800000000000C0C0C00000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000080008000FFFFFF008000
      80008000800080008000800080008000800000FFFF0000FFFF00800080008000
      8000800080000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      000000000000000000000000000000000000000000000000000080008000FFFF
      FF0080008000800080008000800080008000800080000080800000FFFF0000FF
      FF00800080008000800000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000008000
      8000FFFFFF00800080008000800080008000008080008000800000FFFF0000FF
      FF00800080008000800080008000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      000080008000FFFFFF00800080008000800000FFFF0000FFFF0000FFFF008000
      8000800080008000800000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      00000000000080008000FFFFFF00800080008000800080008000800080008000
      8000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000080008000FFFFFF008000800080008000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000800080008000800000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      000000000000000000000000000000000000424D3E000000000000003E000000
      2800000040000000100000000100010000000000800000000000000000000000
      000000000000000000000000FFFFFF00FFFF000000000000FE3F000000000000
      F81F000000000000E00F00000000000080070000000000000003000000000000
      0001000000000000000000000000000000010000000000008001000000000000
      C001000000000000E000000000000000F000000000000000F803000000000000
      FC0F000000000000FE3F00000000000000000000000000000000000000000000
      000000000000}
  end
end

在这里,我将AddActionList方法的可选参数DescriptionCategory保留为默认的空字符串,最终以' Commands '和操作中的Category值结束列表,但您可以指定自己的值,这些值将覆盖这些默认值.

Here I leave the optional parameters Description and Category of the AddActionList method the default empty strings which ends up as 'Commands' and the value of Category from the action list but you can specify your own values which will override these defaults.

这篇关于使用Delphi Open Tools API将我自己的项目添加到Delphi IDE Insight(F6)中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆