Discussion:
Create Main Menu item..
(too old to reply)
Linces
2008-02-22 12:43:32 UTC
Permalink
Hi..

How i create a Main Menu item in the Delphi IDE "Like GExperts do", i do
like code below, but dont work, plz look:

---------------------------------
unit ENDSISWizard;

interface

uses
ToolsAPI, Windows, SysUtils, Classes, Forms, Messages, Menus;

type
TADPCHStickerWizard = class(TNotifierObject, IOTAWizard, IOTAMenuWizard)
public
{ IOTAWizard }
function GetIDString: string;
function GetName: string;
function GetState: TWizardState;
procedure Execute;
{ IOTAMenuWizard }
function GetMenuText: string;
end;

procedure Register;

implementation

procedure Register;
begin
RegisterPackageWizard(TADPCHStickerWizard.Create);
end;

procedure TADPCHStickerWizard.Execute;
var
i : integer;
MainMenu: TMainMenu;
MenuPrincipal: TMenuItem;
begin
inherited Create;
MainMenu := (BorlandIDEServices as INTAServices).MainMenu;
MenuPrincipal := TMenuItem.Create(nil);
MenuPrincipal.Caption := 'E&ndsis Wizard';
MenuPrincipal.Name := 'EndsisWizard';
// Insert menu in the IDE.
MainMenu.Items.Insert(9, MenuPrincipal);
end;

function TADPCHStickerWizard.GetIDString: string;
begin
Result := 'EndSis.EndsisWizard';
Execute;
end;

function TADPCHStickerWizard.GetMenuText: string;
begin
Result := 'E&ndsis Wizard';
end;

function TADPCHStickerWizard.GetName: string;
begin
Result := 'EndSis.EndsisWizard';
end;

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

procedure InitWizard;
begin
// nothing needed
end;

procedure DoneWizard;
begin
// Remove
end;

initialization
InitWizard;

finalization
DoneWizard;


end.

--------------------

Thanks
Lex Y. Li
2008-02-23 07:04:40 UTC
Permalink
Wonder why you don't use IOTAMainMenuService.AddMenuItem just like
GExperts, or CnWizards.
--
Lex Y. Li
http://lextm.blogspot.com

Code Beautifier Collection
http://code.google.com/p/lextudio
Erik Berry
2008-02-24 21:27:27 UTC
Permalink
Post by Linces
How i create a Main Menu item in the Delphi IDE "Like GExperts do", i do
When reporting problem, it is best to provide more information about what
isn't working. For example, is there a menu item but it is disabled, do you
get a crash, or do you get no menu item at all? Have you set breakpoints in
your code to see what is failing? If so, where does it fail?
Post by Linces
type
TADPCHStickerWizard = class(TNotifierObject, IOTAWizard, IOTAMenuWizard)
IOTAMenuWizard is only meant to create a help menu item for your addin. It
isn't designed to add menu items anywhere in the main menu.
Post by Linces
procedure Register;
Set a breakpoint here, and be sure your addin is loading.
Post by Linces
procedure TADPCHStickerWizard.Execute;
This only runs when the user selects your help menu item, which probably
isn't what you want.
Post by Linces
procedure InitWizard;
You probably don't want this to be an empty method.

If you have access to Delphi 7, look at the "D7IOTA.HLP" file for help on the
OTA. Also, see here for some examples:
http://www.gexperts.org/opentools/

Erik
lhaymehr
2008-02-28 13:40:11 UTC
Permalink
This post might be inappropriate. Click to display it.
Continue reading on narkive:
Loading...