Question

I am working on a project using Delphi 7 and Delphi 2006, i am developing a component that will get certain system information. Now the requirement is that after the component is installed on the system, there should be a menu item on the IDE , like this

enter image description here

and for delphi 7 like this enter image description here

i have searched on the net about adding a menu item but i have not got anything to add an item to the IDE like the one EurekaLog has. can any body tell me how to add the item like EurekaLog or mysql ? is it some where in the registry?

Was it helpful?

Solution

To add a menu to the Delphi IDE you must use the Delphi Open Tools API. from here you can access the Main menu of the delphi IDE using a code like this.

LMainMenu:=(BorlandIDEServices as INTAServices).MainMenu;

or

LMainMenu:=(BorlandIDEServices as INTAServices).GetMainMenu;

And then add the menu items which you want.

Check these links for additional samples

OTHER TIPS

If you want to specifically add a menu item to the HELP menu, and also make it get removed when your package unloads, and handle enable/disable of the items, then this wizard code might be helpful. I took the sample wizard code that GExperts documentation shows as a starter project, and posted it up here as a slightly nicer start project. You can get started very quickly if you grab this code and just extend it:

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

What they mean by "Wizard" is a "simple IDE Expert", that is, something with a menu added to the IDE, that implements IOTAWizard and IOTAMenuWizard. This approach has many benefits and is the way that the GExperts wizards are written.

The core of the code is this starter wizard, which needs to be put into a package (DPK) and installed, and registered with the 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.

The registration code is not shown above, but is included in its own "Reg" (registration) unit if you download this from the link above. A tutorial link is on EDN here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top