欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Delphi Open Tools API - Simple Wizard

程序员文章站 2022-06-07 08:57:09
...

之前向大家简单的介绍了Open Tools API,现在我们就要亲自动手编写一个简单的Wizard,来体验Open Tools API的魅力所在。

在Delphi6中,不再推荐大家使用ExptIntf单元中的TIExpert类做为我们自己编写的Wizard的基类,而是改用TInterfacedObject做为其基类,并实现ToolsAPI单元中的一个或我个接口。

编写一个Wizard必须要实现ToolsAPI单元中的IOTAWizard接口和IOTAWizard的父接口INotifier(尽管Delphi不会调用INotifier接口中的任何方法)。如果你想编写一个Menu Wizard,必须实现IOTAWizard、INotifier和IOTAMenuWizard接口中的方法;如果想编写一个Form Wizard或是Project Wizard,必须实现IOTAWizard、INotifier和IOTARepositoryWizard接口中的方法(在ToolsAPI单元中为IOTARepositoryWizard接口另定义了两个别名IOTAFormWizard和IOTAProjectWizard,分别针对Form Wizard和Project Wizard)。

在Delphi6中,Wizard的注册方式做了相应的变化,在Package中实现的Wizard不再是调用ExptIntf单元中的RegisterLibraryExpert方法,而是改为调用RegisterPackgeWizard方法。如果你编写的Wizard是在DLL中实现的,则不需要调用此方法,而是使用ToolsAPI单元中的IOTAWizardServices接口来注册和移除自己编写的Wizard。

Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi unitSimpleWizard;
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi 
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi 
interface
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi 
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi usesToolsAPI,Dialogs;
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi 
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi type
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi TMSimpleWizard
=class(TInterfacedObject,IOTANotifier,IOTAWizard)
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi 
public
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi 
...{IOTANotifier}
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi procedureAfterSave;
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi procedureBeforeSave;
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi procedureDestroyed;
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi procedureModified;
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi 
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi 
...{IOTAWizard}
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi functionGetIDString:
string;
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi functionGetName:
string;
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi functionGetState:TWizardState;
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi procedureExecute;
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi end;
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi 
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi implementation
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi 
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi functionTMSimpleWizard.AfterSave;
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi begin
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi 
//DoNothing
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi 
end;
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi 
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi functionTMSimpleWizard.BeforeSave;
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi begin
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi 
//DoNothing
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi 
end;
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi 
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi procedureTMSimpleWizard.Destroyed;
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi begin
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi 
//DoNothing
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi 
end;
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi 
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi procedureTMSimpleWizard.Execute;
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi begin
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi ShowMessage(
'ThisWizardistryingtodosomethinguseful.');
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi end;
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi 
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi functionTMSimpleWizard.GetIDString:String;
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi begin
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi Result:
='ChirsMao.SimpleWizard';
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi end;
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi 
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi functionTMSimpleWizard.GetName:String;
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi begin
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi Result:
='SimpleWizard';
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi end;
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi 
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi functionTMSimpleWizard.GetState:TWizardState;
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi begin
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi Result:
=[wsEnabled];
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi end;
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi 
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi procedureTMSimpleWizard.Modified;
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi begin
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi 
//DoNothing
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi 
end;

在DLL中实现Wizard,必须在Uses从句中第一个引用ShareMem单元。并且要在DLL的Terminate方法中手工移除掉注册到IDE中的Wizard。

Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi LibrarySiampleWizardDLL;
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi 
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi usesShareMem,ToolsAPI,SiampleWizard;
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi 
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi var
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi Index:Integer
=-1;//全局变量,保存Wizard添加到IDE中的索引号
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi 

Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi procedureTerminate;
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi var
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi Services:IOTAWizardServices;
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi begin
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi Services:
=BorlandIDEServicesasIOTAWizardServices;
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi Services.RemoveWizard(Index);
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi end;
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi 
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi functionInitialize(
constServices:IBorlandIDEServices;RegisterProc:TWizardRegisterProc;varTerminateProc:TWizardTerminateProc):Boolean;stdcall;
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi var
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi WizardServices:IOTAWizardServices;
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi begin
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi 
//如果你使用了VCL*.BPL,否则需要保存这个接口变量
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi 
BorlandIDEServices:=Services;
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi WizardServices:
=BorlandIDEServicesasIOTAWizardServices;
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi WizardServices.AddWizard(TSimpleWizard.Create);
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi TerminateProc:
=Terminate;
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi Result:
=True;
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi end;
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi 
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi Exports
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi Initialize
asWizardEntryPoint;
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi 
Delphi Open Tools API - Simple Wizard
            
    
    博客分类: Delphi delphi end.

版权声明:本文为博主原创文章,未经博主允许不得转载。

相关标签: delphi