🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.delphi.opentoolsapi
4 messages
4 total messages Started by Linces Fri, 22 Feb 2008 12:43
Create Main Menu item..
#124
Author: Linces
Date: Fri, 22 Feb 2008 12:43
92 lines
2772 bytes
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
Re: Create Main Menu item..
#125
Author: Lex Y. Li
Date: Sat, 23 Feb 2008 07:04
9 lines
1200 bytes
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
Re: Create Main Menu item..
#128
Author: Erik Berry
Date: Sun, 24 Feb 2008 21:27
33 lines
2069 bytes
Linces wrote:
> How i create a Main Menu item in the Delphi IDE "Like GExperts do", i do 
> like code below, but dont work, plz look:

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?

> 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.

> procedure Register;

Set a breakpoint here, and be sure your addin is loading.

> procedure TADPCHStickerWizard.Execute;

This only runs when the user selects your help menu item, which probably 
isn't what you want.

> 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
Re: Create Main Menu item..
#135
Author: lhaymehr
Date: Thu, 28 Feb 2008 13:40
145 lines
4640 bytes
Here's a snippet. Hack it a bit and you'll figure it out. This adds a menu 
item in the Tools menu. What you need to do is add this into a bpl project, 
add DesignIDE in the project uses clause, compile, install.



unit LibraryEditorExpert;

interface

uses ToolsAPI;

procedure Register;

implementation

uses
  SysUtils, Menus, LibraryEditorFormU;

type
  TUltraTurboDelphiLibraryEditorExpert = class(TInterfacedObject, 
IOTAWizard, IOTANotifier)
  private
    FLibraryEditorItem: TMenuItem;
    procedure AddMenuItems;
    procedure RemoveMenuItems;
  public
    constructor Create;
    destructor Destroy; override;
    function GetIDString: string;
    procedure Execute;
    function GetName: string;
    function GetState: TWizardState;
    procedure AfterSave;
    procedure BeforeSave;
    procedure Destroyed;
    procedure Modified;
    procedure LibraryEditorItemClick(Sender: TObject);
  end;

procedure Register;
begin
  RegisterPackageWizard(TUltraTurboDelphiLibraryEditorExpert.Create);
  TLibraryEditorForm.CreateLibraryEditorForm;
end;

{ TUltraTurboDelphiLibraryEditorExpert }

procedure TUltraTurboDelphiLibraryEditorExpert.AddMenuItems;
var
  MainMenu: TMainMenu;
  ToolsMenu: TMenuItem;
  i: Integer;
begin
  inherited;
  MainMenu := (BorlandIDEServices as INTAServices).MainMenu;

  // Use default position to start with.
  ToolsMenu := MainMenu.Items[8];

  // Find "Tools" menu in main menu bar.
  for I := 0 to MainMenu.Items.Count - 1 do
    if CompareText(MainMenu.Items[I].Name, 'ToolsMenu') = 0 then
    begin
      ToolsMenu := MainMenu.Items[I];
      Break;
    end;

  // Insert expert menu items.
  // References are kept so they can be freed when expert is removed.
  FLibraryEditorItem := Menus.NewItem('Ultra Turbo Delphi Library Editor', 
0, False, True,
    LibraryEditorItemClick, 0, 'UltraTurboDelphiLibraryEditorItem');
  ToolsMenu.InsertComponent(FLibraryEditorItem);
  ToolsMenu.Insert(0, FLibraryEditorItem);
end;

procedure TUltraTurboDelphiLibraryEditorExpert.AfterSave;
begin
  //
end;

procedure TUltraTurboDelphiLibraryEditorExpert.BeforeSave;
begin
  //
end;

constructor TUltraTurboDelphiLibraryEditorExpert.Create;
begin
  AddMenuItems;
end;

destructor TUltraTurboDelphiLibraryEditorExpert.Destroy;
begin
  RemoveMenuItems;
  inherited;
end;

procedure TUltraTurboDelphiLibraryEditorExpert.Destroyed;
begin
  TLibraryEditorForm.RemoveLibraryEditorForm;
end;

procedure TUltraTurboDelphiLibraryEditorExpert.Execute;
begin
  //
end;

function TUltraTurboDelphiLibraryEditorExpert.GetIDString: string;
begin
  Result := '{0EE9F5C4-4890-4600-BFFF-37C0A3633DFF}';
end;

function TUltraTurboDelphiLibraryEditorExpert.GetName: string;
begin
  Result := 'UltraTurboDelphi.UltraTurboDelphiLibraryEditor';
end;

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

procedure TUltraTurboDelphiLibraryEditorExpert.Modified;
begin
  //
end;

procedure 
TUltraTurboDelphiLibraryEditorExpert.LibraryEditorItemClick(Sender: 
TObject);
begin
  TLibraryEditorForm.ShowLibraryEditorForm;
end;

procedure TUltraTurboDelphiLibraryEditorExpert.RemoveMenuItems;
begin
  FLibraryEditorItem.Free;
end;

initialization
finalization
  TLibraryEditorForm.RemoveLibraryEditorForm;

end. 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads