[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 179
  • Last Modified:

own menu for my expert

Hi,
I'm working on experts ;) yes, I know
that you know.
How can I put my expert in it's own
Main menu ?
I mean I know how to put it in any menu
but like gexpert, I'd like to have
my own. How can I achieve that. I
need source code. Thanks.
0
jeurk
Asked:
jeurk
1 Solution
 
MadshiCommented:
listening...  (Well yes, you see, I'm really interested in this topic...  :-)
0
 
intheCommented:
this will add an item to the right of "file"(posistion 1):


unit U_InMenu;

interface
uses Windows,Dialogs, ExptIntf, ToolIntf, EditIntf, SysUtils;

type
  TTestExpert = class(TIExpert)
    private
    { Private declarations }
   FMenuItem: TIMenuItemIntf;
    public
    { Public declarations }
    constructor Create;
    destructor Destroy; override;
     procedure MenuClick(Sender: TIMenuItemIntf);
    procedure Execute; override;
    function GetAuthor: string; override;
    function GetComment: string; override;
    function GetGlyph: HICON; override;
    function GetIDString: string; override;
    function GetMenuText: string; override;
    function GetName: string; override;
    function GetPage: string; override;
    function GetState: TExpertState; override;
    function GetStyle: TExpertStyle; override;
  end;

procedure Register;

implementation

constructor TTestExpert.Create;
var
  MainMenu: TIMainMenuIntf;
  Target: TIMenuItemIntf;
  Parent: TIMenuItemIntf;
begin
  inherited create;
  MainMenu := ToolServices.GetMainMenu; // get main menu interface object
  Target := MainMenu.FindMenuItem('FileMenu'); // get target menu intf object
  Parent := Target.GetParent; // get main menu parent of target
  FMenuItem := parent.InsertItem( 1, 'Inthe.Future', 'Test', 'Barys Test expert',0, 0, 0,
  [mfVisible, mfEnabled], MenuClick); // create the new menu item object
  Target.free; // free all interface objects
  Parent.free; // created except for FMenuItem
  MainMenu.free; // which is freed when Delphi quits
end;

destructor TTestExpert.Destroy;
begin
  FMenuItem.free; // free the new menu interface object
  inherited Destroy;
end;

procedure TTestExpert.MenuClick(Sender: TIMenuItemIntf);
begin
showmessage('clicked');
end;

procedure TTestExpert.Execute;
begin
  showmessage('Barrys Test Expert');
end;

function TTestExpert.GetAuthor: string;
begin
  result := 'Inthe.Future';
end;

function TTestExpert.GetStyle: TExpertStyle;
begin
   Result := esStandard;
end;

function TTestExpert.GetState: TExpertState;
begin
  result := [esEnabled,esChecked];
end;

function TTestExpert.GetComment: string;
begin
  result := 'Test to put item in help menu';
end;

function TTestExpert.GetIDString: string;
begin
  result := 'Inthe.Future.Expert';
end;

function TTestExpert.GetMenuText: string;
begin
  result := 'Inthe Expert';
end;

function TTestExpert.GetName: string;
begin
  result := 'Test Expert';
end;

function TTestExpert.GetPage: string;
begin
  result := '';
end;

function TTestExpert.GetGlyph: HICON;
begin
  result := 0;
end;

procedure Register;
begin
  RegisterLibraryExpert(TTestExpert.Create); // register the expert
end;

end.

Regards Barry
                ;-)
0
 
jeurkAuthor Commented:
I'll check this out. Thanks
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
rwilson032697Commented:
Nice code Barry...

Cheers,

Raymond.
0
 
jeurkAuthor Commented:
Hi,
This only put a menu entry in the main menu, no ?
I want to be able to do that, ok.
and to add some entries in it.
How can I do that ?
0
 
jeurkAuthor Commented:
And I'd like to choose at which
place I insert the first menu.
I'd like to have it before the tools menu.
Thanks
0
 
jeurkAuthor Commented:
Ok, it's done.
Thanks to you and to hidden paths of delphi 3.
Thanks for your help.
0
 
jeurkAuthor Commented:
Thanks again.
0
 
intheCommented:
sorry forgot to comment better that
InsertItem(1 ...was the position(file menu is at position 0)
cheers
0
 
jeurkAuthor Commented:
No problem.
I changed it but did no longer worked.
The error was elsewhere but you might
know, it's not easy, all that expert
and package devel...
CU
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now