|
|
|||
Home Products Downloads Registered users Support Prices Order Primary Subscription |
|
||
Let's goWhere? \QDemo\First\FirstAddIn.dpr The components and COM development in Borland Delphi is not a visual process. That's why this document contains a lot of well-commented source code. To create a COM add-in with Add-in Express you should make two standard steps described below. Step #1 - Add-in Express WizardTo create a COM Add-in project choose File|New|Others (File|New for Delphi 5) and go to the Add-in Express tab in the New Items window and double-click the MS Office COM Add-in icon. This will start the Add-in Express Wizard. With this, you can specify a name of the COM add-in project, a destination folder for the project, one or several host applications COM add-in is being designed for, a display name for the COM Add-in coclass and more. ![]() First, you should name the add-in project. For example we name the first add-in project FirstAddIn and place it into the C:\ADXTest folder. ![]() Second, you should choose one or several host applications COM add-in is being designed for. In this example we select only MS Excel. ![]() Third, you should specify a coclass name that will be used as a name of add-in interfaces and a name of the class that implement add-in. Also the Add-in Express Wizard allows you to specify an add-in display name and an add-in description that will be displayed in the COM Add-in Manager of the host application. ![]() Finally, you should check your settings and press the Finish button <g> ![]() When the Add-in Express Wizard is finished, the COM Add-in project will be created and opened in Delphi IDE. The COM Add-in project is an ActiveX library that contains only one Automation object that implements the COM Add-in. The sample project includes the following modules:
Among all modules described here only the ProjectName_IMPL.pas unit is of importance for you. In this example and in all of your feature projects this unit contains the following code:
unit FirstAddIn_IMPL;
interface uses
ComObj, ComServ, ActiveX, Dialogs, axpAddIn, FirstAddIn_TLB;
type
TMyFirstAddIn = class(TaxpAddIn, IMyFirstAddIn)
protected
{ Protected declarations }
end;
procedure AddIn_Initialize; override; procedure AddIn_Finalize; override; procedure AddIn_ControlEvent(const Tag: string; ICtrl: IaxpControl); override; implementation { TMyFirstAddIn } procedure TMyFirstAddIn.AddIn_Initialize; begin
inherited;
end;
procedure TMyFirstAddIn.AddIn_Finalize; begin
inherited;
end;
procedure TMyFirstAddIn.AddIn_ControlEvent(const Tag: string;
ICtrl: IaxpControl);
beginend; initialization
TaxpFactory.CreateEx(ComServer, TMyFirstAddIn, Class_MyFirstAddIn,
end.
[ohaExcel], 'First COM Add-in',
'The first COM add-in for MS Excel that is being designed through Add-in Express'); The TMyFirstAddIn class implements the COM Add-in (as Automation object) and is a descendant of the TaxpAddIn class. The TaxpAddIn class implements the IDTExtensibility2 interface in order to make the in-process Automation Server be a real COM Add-in and it defines the way of development. See step #2 for more details. |
Developed forDelphi 5, 6, 7
[ Download it ] Immediate shipment
|