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

对于像这样的delphi 7

我已经在网上搜索过关于添加菜单项的内容,但我还没有找到像EurekaLog那样可以向IDE添加菜单项的内容。有人能告诉我如何添加像EurekaLog或mysql这样的项目吗?它是注册表中的某个位置吗?
发布于 2012-04-23 16:04:23
要向Delphi IDE添加菜单,必须使用Delphi Open Tools API。在这里,您可以使用如下代码访问delphi IDE的主菜单。
LMainMenu:=(BorlandIDEServices as INTAServices).MainMenu;或
LMainMenu:=(BorlandIDEServices as INTAServices).GetMainMenu;然后添加所需的菜单项。
有关其他示例,请查看这些链接
发布于 2012-04-25 07:00:16
如果您想专门将菜单项添加到HELP菜单中,并在卸载包时将其删除,并处理菜单项的启用/禁用,则此向导代码可能会有所帮助。我采用了GExperts文档显示为起始项目的示例向导代码,并将其作为稍微好一点的起始项目发布在这里。如果你抓取这段代码并扩展它,你可以很快上手:
https://bitbucket.org/wpostma/helloworldwizard/
他们所说的“向导”指的是“简单的集成开发环境专家”,即在集成开发环境中添加菜单的东西,用于实现IOTAWizard和IOTAMenuWizard。这种方法有很多好处,并且是编写GExperts向导的方式。
代码的核心是这个启动器向导,它需要放到一个包(DPK)中并安装,并在IDE中注册:
// "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.
https://stackoverflow.com/questions/10276768
复制相似问题