?
Solved

expert in a package

Posted on 2000-01-03
9
Medium Priority
?
395 Views
Last Modified: 2010-04-06
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.
0
Comment
Question by:jeurk
  • 4
  • 4
9 Comments
 
LVL 17

Expert Comment

by:inthe
ID: 2320532
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
 
LVL 4

Author Comment

by:jeurk
ID: 2320550
'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
 
LVL 4

Author Comment

by:jeurk
ID: 2320656
Hi,
I cannot make it work.
Another hint ?

By the way, how can I debug it ?
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.

 
LVL 17

Expert Comment

by:inthe
ID: 2320694
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
 
LVL 20

Expert Comment

by:Madshi
ID: 2321079
listening...
0
 
LVL 17

Accepted Solution

by:
inthe earned 600 total points
ID: 2321429
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
 
LVL 4

Author Comment

by:jeurk
ID: 2322130
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
 
LVL 17

Expert Comment

by:inthe
ID: 2322792
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
 
LVL 4

Author Comment

by:jeurk
ID: 2322814
Let's say it's because of the copyright ;)

CU
0

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Stellar Phoenix SQL Database Repair software easily fixes the suspect mode issue of SQL Server database. It is a simple process to bring the database from suspect mode to normal mode. Check out the video and fix the SQL database suspect mode problem.
Hi, this video explains a free download that you can incorporate into your Access databases, or use stand-alone for contact management. Contacts -- Names, Addresses, Phone Numbers, eMail Addresses, Websites, Lists, Projects, Notes, Attachments…
Suggested Courses

589 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question