📄 usecplug_in_reg.pas
字号:
unit uSecPlug_In_reg;
interface
uses
Windows, SysUtils, Classes, Controls, ToolsApi,uSecPlugModule,Dialogs,Graphics,
{$IFDEF VER140} DesignEditors, DesignIntf {$ELSE}
{$IFDEF VER150} DesignEditors, DesignIntf {$ELSE} DsgnIntf {$ENDIF}{$ENDIF};
type
TIESecPlugModule=class(TNotifierObject,IOTAWizard,IOTARepositoryWizard,IOTAFormWizard)
public
function GetAuthor: string;
function GetComment: string;
function GetPage: string;
function GetGlyph: Cardinal;
function GetIDString: string;
function GetName: string;
function GetState: TWizardState;
procedure Execute;
end;
TIESecPlugModuleCreator=class(TNotifierObject,IOTACreator,IOTAModuleCreator)
private
FImplFileName:string;
FFormName:string;
public
FFormEditor: IOTAFormEditor;
function GetAncestorName: string;
function GetImplFileName: string;
function GetIntfFileName: string;
function GetFormName: string;
function GetMainForm: Boolean;
function GetShowForm: Boolean;
function GetShowSource: Boolean;
function NewFormFile(const FormIdent, AncestorIdent: string): IOTAFile;
function NewImplSource(const ModuleIdent, FormIdent, AncestorIdent: string): IOTAFile;
function NewIntfSource(const ModuleIdent, FormIdent, AncestorIdent: string): IOTAFile;
procedure FormCreated(const FormEditor: IOTAFormEditor);
function GetCreatorType: string;
function GetExisting: Boolean;
function GetFileSystem: string;
function GetOwner: IOTAModule;
function GetUnnamed: Boolean;
end;
TIESecPlugSourceFile=class(TInterfacedObject,IOTAFile)
private
FSource:string;
public
constructor create(const source:string);
function GetSource: string;
function GetAge: TDateTime;
end;
TIESecPlugLibrary=class(TNotifierObject,IOTAWizard,IOTARepositoryWizard,IOTAProjectWizard)
public
function GetAuthor: string;
function GetComment: string;
function GetPage: string;
function GetGlyph: Cardinal;
function GetIDString: string;
function GetName: string;
function GetState: TWizardState;
procedure Execute;
end;
TIESecPlugLibraryCreator=class(TInterfacedObject,IOTACreator,IOTAProjectCreator)
public
function GetFileName: string;
function GetOptionFileName: string;
function GetShowSource: Boolean;
procedure NewDefaultModule;
function NewOptionSource(const ProjectName: string): IOTAFile;
procedure NewProjectResource(const Project: IOTAProject);
function NewProjectSource(const ProjectName: string): IOTAFile;
function GetCreatorType: string;
function GetExisting: Boolean;
function GetFileSystem: string;
function GetOwner: IOTAModule;
function GetUnnamed: Boolean;
end;
procedure Register;
implementation
{$R SecPlugRes.RES}
procedure Register;
begin
RegisterCustomModule(TSecPlugModule, TCustomModule);
//RegisterPackageWizard(TIESecPlugModule.Create);
RegisterPackageWizard(TIESecPlugLibrary.Create);
end;
{ TIESecPlugModule }
procedure TIESecPlugModule.Execute;
begin
(BorlandIDEServices as IOTAModuleServices).CreateModule(TIESecPlugModuleCreator.Create);
end;
function TIESecPlugModule.GetAuthor: string;
begin
result:='loskiller';
end;
function TIESecPlugModule.GetComment: string;
begin
Result:='SecPlugModule for CartmanLand';
end;
function TIESecPlugModule.GetGlyph: Cardinal;
begin
Result:=LoadIcon(HInstance,'SecPlugModuleIco');
end;
function TIESecPlugModule.GetIDString: string;
begin
Result:='Loskiller.TIESecPlugModule';
end;
function TIESecPlugModule.GetName: string;
begin
Result:='SecPlugModule';
end;
function TIESecPlugModule.GetPage: string;
begin
Result:='SecPlug_In';
end;
function TIESecPlugModule.GetState: TWizardState;
begin
Result:=[wsEnabled];
end;
{ TIESecPlugModuleCreator }
procedure TIESecPlugModuleCreator.FormCreated(
const FormEditor: IOTAFormEditor);
var
FImageList:TImageList;
ToolsPlugBmp:TBitMap;
begin
FImageList:=TImageList((FormEditor as INTAFormEditor).FormDesigner.GetComponent('ImageList1'));
if FImageList<>nil then
begin
ToolsPlugBmp:=TBitMap.Create;
ToolsPlugBmp.Handle:=LoadBitmap(hinstance,'ToolsPlugBmp');
FImageList.AddMasked(ToolsPlugBmp,clwhite);
ToolsPlugBmp.Free;
end;
end;
function TIESecPlugModuleCreator.GetAncestorName: string;
begin
result:='SecPlugModule';
end;
function TIESecPlugModuleCreator.GetCreatorType: string;
begin
result:=sForm;
end;
function TIESecPlugModuleCreator.GetExisting: Boolean;
begin
result:=false;
end;
function TIESecPlugModuleCreator.GetFileSystem: string;
begin
result:='';
end;
function TIESecPlugModuleCreator.GetFormName: string;
begin
result:=FFormName;
end;
function TIESecPlugModuleCreator.GetImplFileName: string;
begin
result:=FImplFileName;
end;
function TIESecPlugModuleCreator.GetIntfFileName: string;
begin
result:='';
end;
function TIESecPlugModuleCreator.GetMainForm: Boolean;
begin
result:=false;
end;
function TIESecPlugModuleCreator.GetOwner: IOTAModule;
var
ModuleServices:IOTAModuleServices;
Module,NewModule:IOTAModule;
begin
result:=nil;
ModuleServices:=BorlandIDEServices as IOTAModuleServices;
Module:=ModuleServices.CurrentModule;
if Module<>nil then
begin
if Module.QueryInterface(IOTAProject,NewModule)=S_OK then
begin
result:=NewModule;
end
else
begin
if Module.OwnerModuleCount>0 then
begin
NewModule:=Module.OwnerModules[0];
if NewModule<>nil then
if NewModule.QueryInterface(IOTAProject,result)<>S_OK then
begin
NewModule:=nil;
//raise Exception.Create('SecPlugModule can not be added to a package. Please create or open a SecPlugLibrary Project.');
end;
end
else
begin
//raise Exception.Create('SecPlugModule can not be added to a package. Please create or open a SecPlugLibrary Project.');
end;
end;
end;
end;
function TIESecPlugModuleCreator.GetShowForm: Boolean;
begin
result:=true;
end;
function TIESecPlugModuleCreator.GetShowSource: Boolean;
begin
result:=true;
end;
function TIESecPlugModuleCreator.GetUnnamed: Boolean;
begin
result:=true;
end;
function TIESecPlugModuleCreator.NewFormFile(const FormIdent,
AncestorIdent: string): IOTAFile;
var
Source:string;
const
CRLF = #13#10;
CRLF2 = #13#10#13#10;
begin
Source:='object '+FormIdent+': T'+FormIdent+CRLF+
' OldCreateOrder = False'+CRLF+
' PlugType = ptMain'+CRLF+
' Left = 192'+CRLF+
' Top = 107'+CRLF+
' Height = 150'+CRLF+
' Width = 215'+CRLF+
' PlugImages = ImageList1'+CRLF+
' object ImageList1: TImageList'+CRLF+
' Left = 24'+CRLF+
' Top = 24'+CRLF+
' end'+CRLF+
'end';
result:=TIESecPlugSourceFile.create(source);
end;
function TIESecPlugModuleCreator.NewImplSource(const ModuleIdent,
FormIdent, AncestorIdent: string): IOTAFile;
var
Source:string;
const
CRLF = #13#10;
CRLF2 = #13#10#13#10;
begin
FFormName:=FormIdent;
FImplFileName:=ModuleIdent;
Source:=Source+'unit '+ModuleIdent+';'+CRLF2+
'interface'+CRLF2+
'uses'+CRLF+
' Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, '+CRLF+
' Variants, uSecPlugModule, uIAppInf, uSecPlugInf;'+CRLF2+
'type'+CRLF+
' T'+FormIdent+' = class(T'+AncestorIdent+')'+CRLF+
' ImageList1: TImageList;'+CRLF+
' private'+CRLF+
' { Private declarations }'+CRLF+
' public'+CRLF+
' { Public declarations }'+CRLF+
' end;'+CRLF2+
'var '+CRLF+ ' ' + FormIdent+': T'+FormIdent+';'+CRLF2+
'function LoadSecPlugModule(const App:IApp):ISecPlug;stdcall;'+CRLF2+
'procedure UnLoadSecPlugModule;stdcall;'+CRLF2+
'implementation'+CRLF2+
'{$R *.DFM}'+CRLF2+
'function LoadSecPlugModule(const App:IApp):ISecPlug;stdcall;'+CRLF+
'begin'+CRLF+
' '+FormIdent+':=T'+FormIdent+'.create(nil);'+CRLF+
' '+FormIdent+'.App:=App;'+CRLF+
' result:='+FormIdent+'.TheSecPlug;'+CRLF+
'end;'+CRLF2+
'procedure UnLoadSecPlugModule;stdcall;'+CRLF+
'begin'+CRLF+
' if '+FormIdent+'<>nil then'+CRLF+
' '+FormIdent+'.Free;'+CRLF+
'end;'+CRLF2+
'end.'+CRLF;
result:=TIESecPlugSourceFile.create(source);
end;
function TIESecPlugModuleCreator.NewIntfSource(const ModuleIdent,
FormIdent, AncestorIdent: string): IOTAFile;
begin
result:=nil;
end;
{ TIESecPlugSourceFile }
constructor TIESecPlugSourceFile.create(const source: string);
begin
FSource:=Source;
end;
function TIESecPlugSourceFile.GetAge: TDateTime;
begin
result:=-1;
end;
function TIESecPlugSourceFile.GetSource: string;
begin
result:=FSource;
end;
{ TIESecPlugLibrary }
procedure TIESecPlugLibrary.Execute;
var
ModuleServices:IOTAModuleServices;
begin
ModuleServices:=(BorlandIDEServices as IOTAModuleServices);
ModuleServices.CreateModule(TIESecPlugLibraryCreator.create);
ModuleServices.CreateModule(TIESecPlugModuleCreator.create);
end;
function TIESecPlugLibrary.GetAuthor: string;
begin
result:='loskiller';
end;
function TIESecPlugLibrary.GetComment: string;
begin
result:='SecPlugLibrary for CartmanLand';
end;
function TIESecPlugLibrary.GetGlyph: Cardinal;
begin
Result:=LoadIcon(HInstance,'SecPlugLibraryIco');
end;
function TIESecPlugLibrary.GetIDString: string;
begin
result:='Loskiller.TIESecPlugLibrary';
end;
function TIESecPlugLibrary.GetName: string;
begin
result:='SecPlugLibrary';
end;
function TIESecPlugLibrary.GetPage: string;
begin
result:='SecPlug_In';
end;
function TIESecPlugLibrary.GetState: TWizardState;
begin
result:=[wsEnabled];
end;
{ TIESecPlugLibraryCreator }
function TIESecPlugLibraryCreator.GetCreatorType: string;
begin
result:=sLibrary;
end;
function TIESecPlugLibraryCreator.GetExisting: Boolean;
begin
result:=false;
end;
function TIESecPlugLibraryCreator.GetFileName: string;
var
ModuleServices:IOTAModuleServices;
AUnitIdent,AClassName,AFileName:string;
begin
ModuleServices:=(BorlandIDEServices as IOTAModuleServices);
ModuleServices.GetNewModuleAndClassName('Project',AUnitIdent,AClassName,AFileName);
result:=ExtractFilePath(AFileName)+AClassName+'.dpr';
end;
function TIESecPlugLibraryCreator.GetFileSystem: string;
begin
result:='';
end;
function TIESecPlugLibraryCreator.GetOptionFileName: string;
begin
result:='';
end;
function TIESecPlugLibraryCreator.GetOwner: IOTAModule;
var
ModuleServices:IOTAModuleServices;
i:integer;
Module:IOTAModule;
ProjectGroup:IOTAProjectGroup;
begin
result:=nil;
ModuleServices:=BorlandIDEServices as IOTAModuleServices;
for i:=0 to ModuleServices.ModuleCount-1 do
begin
Module:=ModuleServices.Modules[i];
if Module.QueryInterface(IOTAProjectGroup,ProjectGroup)=S_OK then
begin
result:=ProjectGroup;
break;
end;
end;
end;
function TIESecPlugLibraryCreator.GetShowSource: Boolean;
begin
result:=true;
end;
function TIESecPlugLibraryCreator.GetUnnamed: Boolean;
begin
result:=true;
end;
procedure TIESecPlugLibraryCreator.NewDefaultModule;
begin
end;
function TIESecPlugLibraryCreator.NewOptionSource(
const ProjectName: string): IOTAFile;
begin
end;
procedure TIESecPlugLibraryCreator.NewProjectResource(
const Project: IOTAProject);
begin
end;
function TIESecPlugLibraryCreator.NewProjectSource(
const ProjectName: string): IOTAFile;
var
Source:string;
const
CRLF = #13#10;
CRLF2 = #13#10#13#10;
begin
Source:='library '+ProjectName+';'+CRLF2+
'uses'+CRLF+
' SysUtils,'+CRLF+' Classes;'+CRLF2+
'{$R *.res}'+CRLF2+
'exports'+CRLF+
' LoadSecPlugModule,'+CRLF+
' UnLoadSecPlugModule;'+CRLF2+
'begin'+CRLF+'end.';
result:=TIESecPlugSourceFile.create(Source);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -