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.
LVL 4
jeurkAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jeurkAuthor Commented:
I'll check this out. Thanks
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.