首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Delphi IDE自定义菜单项,如何添加?

Delphi IDE自定义菜单项,如何添加?
EN

Stack Overflow用户
提问于 2012-04-23 15:51:35
回答 2查看 3.2K关注 0票数 6

我正在从事一个使用Delphi 7Delphi 2006的项目,我正在开发一个组件,将获得某些系统信息。现在的要求是,在系统上安装组件后,IDE上应该有一个菜单项,如下所示

对于像这样的delphi 7

我已经在网上搜索过关于添加菜单项的内容,但我还没有找到像EurekaLog那样可以向IDE添加菜单项的内容。有人能告诉我如何添加像EurekaLogmysql这样的项目吗?它是注册表中的某个位置吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-04-23 16:04:23

要向Delphi IDE添加菜单,必须使用Delphi Open Tools API。在这里,您可以使用如下代码访问delphi IDE的主菜单。

代码语言:javascript
复制
LMainMenu:=(BorlandIDEServices as INTAServices).MainMenu;

代码语言:javascript
复制
LMainMenu:=(BorlandIDEServices as INTAServices).GetMainMenu;

然后添加所需的菜单项。

有关其他示例,请查看这些链接

  • Open Tools API Chapter 15: IDE Main Menus
  • Introduction to the Delphi Open Tools API
  • How can I add a menu item to the IDE’s main menu?
票数 15
EN

Stack Overflow用户

发布于 2012-04-25 07:00:16

如果您想专门将菜单项添加到HELP菜单中,并在卸载包时将其删除,并处理菜单项的启用/禁用,则此向导代码可能会有所帮助。我采用了GExperts文档显示为起始项目的示例向导代码,并将其作为稍微好一点的起始项目发布在这里。如果你抓取这段代码并扩展它,你可以很快上手:

https://bitbucket.org/wpostma/helloworldwizard/

他们所说的“向导”指的是“简单的集成开发环境专家”,即在集成开发环境中添加菜单的东西,用于实现IOTAWizard和IOTAMenuWizard。这种方法有很多好处,并且是编写GExperts向导的方式。

代码的核心是这个启动器向导,它需要放到一个包(DPK)中并安装,并在IDE中注册:

代码语言:javascript
复制
// "Hello World!" for the OpenTools API (IDE versions 4 or greater)
// By Erik Berry: http://www.gexperts.org/, eberry@gexperts.org

unit HelloWizardUnit;

interface

uses ToolsAPI;

type
  // TNotifierObject has stub implementations for the necessary but
  // unused IOTANotifer methods
  THelloWizard = class(TNotifierObject, IOTAMenuWizard, IOTAWizard)
  public
        // IOTAWizard interface methods(required for all wizards/experts)
        function GetIDString: string;
        function GetName: string;
        function GetState: TWizardState;
        procedure Execute;
        // IOTAMenuWizard (creates a simple menu item on the help menu)
        function GetMenuText: string;
  end;


implementation

uses Dialogs;

procedure THelloWizard.Execute;
begin
  ShowMessage('Hello World!');
end;

function THelloWizard.GetIDString: string;
begin
  Result := 'EB.HelloWizard';
end;

function THelloWizard.GetMenuText: string;
begin
  Result := '&Hello Wizard';
end;

function THelloWizard.GetName: string;
begin
  Result := 'Hello Wizard';
end;

function THelloWizard.GetState: TWizardState;
begin
  Result := [wsEnabled];
end;

end.

上面没有显示注册码,但如果您从上面的链接下载,注册码就包含在它自己的"Reg“(注册)单元中。A tutorial link is on EDN here.

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10276768

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档