📄 uasrvobjwizard.pas
字号:
{******************************************************************************************}
{ }
{ Universal Agent on demond SDK }
{ }
{ }
{ COPYRIGHT }
{ ========= }
{ The UA SDK (software) is Copyright (C) 2001-2003, by vinson zeng(曾胡龙). }
{ All rights reserved. }
{ The authors - vinson zeng (曾胡龙), }
{ exclusively own all copyrights to the Advanced Application }
{ Controls (AppControls) and all other products distributed by Utilmind Solutions(R). }
{ }
{ LIABILITY DISCLAIMER }
{ ==================== }
{ THIS SOFTWARE IS DISTRIBUTED "AS IS" AND WITHOUT WARRANTIES AS TO PERFORMANCE }
{ OF MERCHANTABILITY OR ANY OTHER WARRANTIES WHETHER EXPRESSED OR IMPLIED. }
{ YOU USE IT AT YOUR OWN RISK. THE AUTHOR WILL NOT BE LIABLE FOR DATA LOSS, }
{ DAMAGES, LOSS OF PROFITS OR ANY OTHER KIND OF LOSS WHILE USING OR MISUSING THIS SOFTWARE.}
{ }
{ RESTRICTIONS }
{ ============ }
{ You may not attempt to reverse compile, modify, }
{ translate or disassemble the software in whole or in part. }
{ You may not remove or modify any copyright notice or the method by which }
{ it may be invoked. }
{******************************************************************************************}
unit UASrvObjWizard;
interface
uses
Windows,Toolsapi,Classes,uaSrvObjWizardForm;
type
TUASrvObjWizard = class(TNotifierObject,IOTAWizard,IOTARepositoryWizard,IOTAFormWizard
{$ifdef ver140},IOTARepositoryWizard60{$endif})
public
FForm:TSrvObjWizardForm;
// IOTAWizard
function GetIDString:string;
function GetName:string;
function GetState:TWizardState;
procedure Execute;
// IOTARepositoryWizard
function GetAuthor:string;
function GetComment:string;
function GetPage:string;
{$ifdef ver140} // Delphi 6+
function GetGlyph:Cardinal;
function GetDesigner:string;
{$else} // Delphi -5
function GetGlyph:HICON;
{$endif}
end;
implementation
uses
Dialogs,Controls,SysUtils;
const
LF: string = #13#10;
type
TUASrvObjModuleCreator = class(TInterfacedObject,IOTACreator,IOTAModuleCreator)
private
FForm:TSrvObjWizardForm;
public
constructor Create(aForm:TSrvObjWizardForm);
// IOTACreator
function GetCreatorType:string;
function GetExisting:boolean;
function GetFileSystem:string;
function GetOwner:IOTAModule;
function GetUnnamed:boolean;
// IOTAModuleCreator
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);
end;
TUASrvObjSourceFile = class(TInterfacedObject,IOTAFile)
private
FSource: string;
public
function GetSource:string;
function GetAge:TDateTime;
constructor Create(const Source:string);
end;
function FindModuleInterface(AInterface:TGUID):IUnknown;
var
i:integer;
begin
Result:=nil;
with BorlandIDEServices as IOTAModuleServices do
for i:=0 to ModuleCount-1 do
if (Modules[i].QueryInterface(AInterface,Result)=S_OK) then
break;
end;
function GetProjectGroup:IOTAProjectGroup;
begin
Result:=FindModuleInterface(IOTAProjectGroup) as IOTAProjectGroup;
end;
function GetCurrentProject:IOTAProject;
var
ProjectGroup:IOTAProjectGroup;
begin
ProjectGroup:=GetProjectGroup;
if Assigned(ProjectGroup) then
Result:=ProjectGroup.ActiveProject
else
Result:=FindModuleInterface(IOTAProject) as IOTAProject;
end;
{ TUASrvObjWizard }
procedure TUASrvObjWizard.Execute;
var
Project:IOTAProject;
// s:string;
begin
FForm:=TSrvObjWizardForm.Create(nil);
try
if FForm.ShowModal=mrCancel then exit;
Project:=GetCurrentProject;
if Project=nil then
raise Exception.Create('No project is existing. Please create a project before creating UAServerObject.');
(BorlandIDEServices as IOTAModuleServices).CreateModule(TUASrvObjModuleCreator.Create(FForm));
{ s:= 'UASrvObj_'+FForm.edt_SrvObjName.Text+'.pas';
Project.AddFile(s,true); }
finally
FForm.Free;
end;
end;
function TUASrvObjWizard.GetAuthor: string;
begin
Result:='vinson zeng/infocross studio';
end;
function TUASrvObjWizard.GetComment: string;
begin
Result:='UA SrvObj wizard';
end;
{$ifdef ver140}
function TUASrvObjWizard.GetDesigner: string;
begin
Result:=dAny;
end;
{$endif}
{$ifdef ver140}
function TUASrvObjWizard.GetGlyph: Cardinal;
{$else}
function TUASrvObjWizard.GetGlyph: HICON;
{$endif}
begin
{$IFDEF LINUX}
Result := 0;
{$ELSE}
Result:=LoadIcon(hInstance, 'UASRVOBJWIZARD');
{$ENDIF}
end;
function TUASrvObjWizard.GetIDString: string;
begin
Result:='UA.SrvObjWizard';
end;
function TUASrvObjWizard.GetName: string;
begin
Result:='UA SrvObj wizard';
end;
function TUASrvObjWizard.GetPage: string;
begin
Result:='Universal Agent';
end;
function TUASrvObjWizard.GetState: TWizardState;
begin
Result:=[wsEnabled];
end;
{ TUASrvObjModuleCreator }
constructor TUASrvObjModuleCreator.Create(aForm: TSrvObjWizardForm);
begin
inherited Create;
FForm:=aForm;
end;
procedure TUASrvObjModuleCreator.FormCreated(
const FormEditor: IOTAFormEditor);
begin
end;
function TUASrvObjModuleCreator.GetAncestorName: string;
begin
Result:='';
end;
function TUASrvObjModuleCreator.GetCreatorType: string;
begin
Result:=sUnit;
// Result := sForm;
end;
function TUASrvObjModuleCreator.GetExisting: boolean;
begin
Result:=false;
end;
function TUASrvObjModuleCreator.GetFileSystem: string;
begin
Result:='';
end;
function TUASrvObjModuleCreator.GetFormName: string;
begin
Result:='';
end;
function TUASrvObjModuleCreator.GetImplFileName: string;
begin
// Result:= 'UASrvObj_'+FForm.edt_SrvObjName.Text + '.pas';
Result := '';
end;
function TUASrvObjModuleCreator.GetIntfFileName: string;
//var
// LProject:IOTAProject;
begin
// LProject := GetCurrentProject;
// LProject.
Result:='';
end;
function TUASrvObjModuleCreator.GetMainForm: boolean;
begin
Result:=false;
end;
function TUASrvObjModuleCreator.GetOwner: IOTAModule;
var
ModuleServices:IOTAModuleServices;
Module:IOTAModule;
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
Result:=NewModule
{$ifdef ver140} // Delphi 6+
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -