expert in a package

Hi,
I'm doing an expert.
I'm putting it in a package to avoid me
reloading delphi to test it out.
the expert is a standard add-in project.
everything is fine but the menu entry
does not show up after the package install.
What is wrong and how can I change that.

Here is my source code :
the reg unit :

unit U_ACSCMExpertReg;

interface
uses ExptIntf, U_ACSCMExpert;

procedure register;

implementation

procedure Register;
begin
  RegisterLibraryExpert(TACSCMExpert.Create);
end;

end.
 
the unit by itself :
Unit U_ACSCMExpert;

interface

uses
  ShareMem,
  Windows,
  ExptIntf,
  ToolIntf,
  U_FileOperation;

type
  TACSCMExpert = class(TIExpert)
  private
  public
    constructor Create;
    destructor Destroy; override;

    // Expert UI strings
    function GetName     : string;       override;
    function GetAuthor   : string;       override;
    function GetComment  : string;       override;
    function GetPage     : string;       override;
    function GetGlyph    : HICON;        override;
    function GetStyle    : TExpertStyle; override;
    function GetState    : TExpertState; override;
    function GetIDString : string;       override;
    function GetMenuText : string;       override;

    // Launch the Expert
    procedure Execute; override;
  end;

implementation


constructor TACSCMExpert.Create;
begin
  inherited;
end;

destructor TACSCMExpert.Destroy;
begin
  inherited;
end;

function TACSCMExpert.GetName : string;
begin
  result := 'CM Properties expert';
end;

function TACSCMExpert.GetAuthor : string;
begin
  result := 'ACS JKN';
end;

function TACSCMExpert.GetComment : string;
begin
  result := 'CM Properties expert';
end;

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

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

function TACSCMExpert.GetStyle : TExpertStyle;
begin
  result := esStandard;
end;

function TACSCMExpert.GetState : TExpertState;
begin
  result := [esEnabled];
end;

function TACSCMExpert.GetIDString : string;
begin
  result := 'ACSCM.ACSCMExpert';
end;

function TACSCMExpert.GetMenuText : string;
begin
  result := 'CM Properties expert';
end;

procedure TACSCMExpert.Execute;
begin
     //ExecuteFile
end;


function InitExpert(ToolServices  : TIToolServices;
                    RegisterProc  : TExpertRegisterProc;
                    var Terminate : TExpertTerminateProc) : boolean; stdcall;
begin
  if ExptIntf.ToolServices = nil then
    ExptIntf.ToolServices := ToolServices;
  Result := RegisterProc(TACSCMExpert.Create);
end;

exports InitExpert name ExpertEntryPoint resident;

end.

thanks for your help.

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

intheCommented:
you need to add osmething like:

constructor TCommentExpert.Create;
var
  MainMenu: TIMainMenuIntf;
  Target: TIMenuItemIntf;
  Parent: TIMenuItemIntf;
  i: integer;
begin
  inherited create;
  MainMenu := ToolServices.GetMainMenu; // get main menu interface object
  Target := MainMenu.FindMenuItem('EditSelectAll'); // get target menu intf object
  Parent := Target.GetParent; // get main menu parent of target
  FMenuItem := Parent.InsertItem(Target.GetIndex + 1, 'Comment Toggle', '', 'Comment',0, 0, 0,[mfVisible, mfEnabled], MenuClick);
 // creates 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 TCommentExpert.Destroy;
begin
  FMenuItem.free; // free the new menu interface object
  inherited Destroy;
end;

to the unit to craete and free the menu item.
Regards Barry
0
jeurkAuthor Commented:
'lo,
not sure of that. because by default
the standard expert go to the help
menu. The second thing is that It
worked when it was a dll and not a
package. but i had to reload delphi.

and last the solution should work
under D3 to D5

Thanks for your help. Let's I'll try
that. Maybe it'll work.
0
jeurkAuthor Commented:
Hi,
I cannot make it work.
Another hint ?

By the way, how can I debug it ?
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

intheCommented:
i have  ago in a while see if i make one work.i have an example i downloaded earlier to test with,thats where i pasted that code from.

0
MadshiCommented:
listening...
0
intheCommented:
hi,
can you test this because it always works first time with no restart for me.
save unit as reg_package.pas ,create new package in delphi ,add this file ,click install ,and check help menu for "inthe package"  :

unit Reg_Package;

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

type
  TTestExpert2 = class(TIExpert)
    private
    { Private declarations }
     public
    { Public declarations }
    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

procedure TTestExpert2.Execute;
begin
  showmessage('Barrys Test package');
end;

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

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

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

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

function TTestExpert2.GetIDString: string;
begin
  result := 'Inthe.Future.Expert2';
end;

function TTestExpert2.GetMenuText: string;
begin
  result := 'Inthe Package';
end;

function TTestExpert2.GetName: string;
begin
  result := 'Test Package install';
end;

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

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

procedure Register;
begin
  RegisterLibraryExpert(TTestExpert2.Create);
end;

end.
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:
Hello Barry,
In fact it is working. My problem
yesterday is solved. The problem
was : I don't know what ;)
Everything was ok, but it did not worked
they may be a bug somewhere. I used
a working expert from 'hiden path' and
cut and pasted my stuff in it. It
is exactly the same but now it is
working.

I'll take this as an answer.
Just for you fast help and for your time.
Thank you.
0
intheCommented:
haha i also have hidden paths ,just trying to remember why i the searched net for example when i had a book full in my library ;-)
0
jeurkAuthor Commented:
Let's say it's because of the copyright ;)

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.