📄 texperts.pas
字号:
unit teXperts;
interface
{$INCLUDE teDefs.inc}
{$ifdef D7UP}
{$WARN UNIT_DEPRECATED OFF}
{$endif D7UP}
uses
Windows, SysUtils, Classes, Forms, ToolsAPI;
{$ifdef D7UP}
{$WARN UNIT_DEPRECATED ON}
{$endif D7UP}
type
TFCEmbeddedFormExpert = class(TNotifierObject, IOTAWizard, IOTARepositoryWizard,IOTAFormWizard)
public
function GetName: String;
function GetAuthor: String;
function GetComment: String;
function GetPage: String;
function GetGlyph: Cardinal;
function GetState: TWizardState;
function GetIDString: String;
procedure Execute;
end;
procedure ExecuteFCEmbeddedFormExpert;
implementation
type
TFCEmbeddedFormModuleCreator = class(TInterfacedObject, IOTACreator, IOTAModuleCreator )
public
function GetCreatorType: String;
function GetExisting: Boolean;
function GetFileSystem: String;
function GetOwner: IOTAModule;
function GetUnnamed: Boolean;
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: String; const AncestorIdent: String): IOTAFile;
function NewImplSource(const ModuleIdent: String; const FormIdent: String; const AncestorIdent: String): IOTAFile;
function NewIntfSource(const ModuleIdent: String; const FormIdent: String; const AncestorIdent: String): IOTAFile;
procedure FormCreated(const FormEditor: IOTAFormEditor);
end;
TFCEmbeddedFormSourceFile = class(TInterfacedObject, IOTAFile)
private
FSource: String;
public
function GetSource: String;
function GetAge: TDateTime;
constructor Create(const Source: String);
end;
{$ifdef BCB}
function GetIntfName: string;
begin
Result := '';
end;
function ImplInfSource(const UnitIdent, FormIdent,
AncestorIdent: string): string;
var
Stream: TStringStream;
begin
Stream := TStringStream.Create('');
with Stream do
try
WriteString('//---------------------------------------------------------------------------' + #13#10);
WriteString(Format('#ifndef %sH', [UnitIdent]) + #13#10);
WriteString(Format('#define %sH', [UnitIdent]) + #13#10);
WriteString('//---------------------------------------------------------------------------' + #13#10);
WriteString('#include <Classes.hpp>' + #13#10);
WriteString('#include <Controls.hpp>' + #13#10);
WriteString('#include <StdCtrls.hpp>' + #13#10);
WriteString('#include <Forms.hpp>' + #13#10);
WriteString('#include <FormCont.hpp>' + #13#10);
WriteString('//---------------------------------------------------------------------------' + #13#10);
WriteString(Format('class T%s : public T%s', [FormIdent, AncestorIdent]) + #13#10);
WriteString('{' + #13#10);
WriteString('__published:' + #13#10);
WriteString('private:' + #13#10);
WriteString('public:' + #13#10);
WriteString(Format(' __fastcall T%s(TComponent* Owner);', [FormIdent]) + #13#10);
WriteString('};' + #13#10);
WriteString('//---------------------------------------------------------------------------' + #13#10);
WriteString(Format('extern PACKAGE T%s *%0:s;', [FormIdent]) + #13#10);
WriteString('//---------------------------------------------------------------------------' + #13#10);
WriteString('#endif' + #13#10);
Result := DataString;
finally
Free;
end;
end;
function ImplSource(const UnitIdent, FormIdent,
AncestorIdent: string): string;
var
Stream: TStringStream;
begin
Stream := TStringStream.Create('');
with Stream do
try
WriteString('//---------------------------------------------------------------------------' + #13#10);
WriteString('#include <vcl.h>' + #13#10);
WriteString('#pragma hdrstop' + #13#10);
WriteString(#13#10);
WriteString(Format('#include "%s.h"', [UnitIdent]) + #13#10);
WriteString('//---------------------------------------------------------------------------' + #13#10);
WriteString('#pragma package(smart_init)' + #13#10);
WriteString('#pragma resource "*.dfm"' + #13#10);
WriteString(Format('T%s *%0:s;', [FormIdent]) + #13#10);
WriteString('//---------------------------------------------------------------------------' + #13#10);
WriteString(Format('__fastcall T%s::T%0:s(TComponent* Owner)', [FormIdent]) + #13#10);
WriteString(Format(' : T%s(Owner)', [AncestorIdent]) + #13#10);
WriteString('{' + #13#10);
WriteString('}' + #13#10);
WriteString('//---------------------------------------------------------------------------' + #13#10);
Result := DataString;
finally
Free;
end;
end;
{$else}
function ImplSource(const ModuleIdent, FormIdent,
AncestorIdent: string): string;
var
Stream: TStringStream;
begin
Stream := TStringStream.Create('');
with Stream do
try
WriteString(Format('unit %s;', [ModuleIdent]) + #13#10);
WriteString(#13#10);
WriteString('interface' + #13#10);
WriteString(#13#10);
WriteString('uses' + #13#10);
WriteString(' Windows, Messages, SysUtils, ' +
{$ifdef D6UP}
'Variants, ' +
{$endif D6UP}
'Classes, Graphics, Controls, Forms,' + #13#10);
WriteString(' Dialogs, FormCont;' + #13#10);
WriteString(#13#10);
WriteString('type' + #13#10);
WriteString(Format(' T%s = class(T%s)', [FormIdent, AncestorIdent]) + #13#10);
WriteString(' private' + #13#10);
WriteString(' public' + #13#10);
WriteString(' end;' + #13#10);
WriteString(#13#10);
WriteString('var' + #13#10);
WriteString(Format(' %s: T%0:s;', [FormIdent]) + #13#10);
WriteString(#13#10);
WriteString('implementation' + #13#10);
WriteString(#13#10);
WriteString('{$R *.DFM}' + #13#10);
WriteString(#13#10);
WriteString('end.' + #13#10);
Result := DataString;
finally
Free;
end;
end;
{$endif BCB}
{ TFCEmbeddedFormModuleCreator }
procedure TFCEmbeddedFormModuleCreator.FormCreated(const FormEditor: IOTAFormEditor);
Begin
//
end;
function TFCEmbeddedFormModuleCreator.GetAncestorName: String;
begin
Result := 'FCEmbeddedForm';
end;
function TFCEmbeddedFormModuleCreator.GetCreatorType: String;
Begin
Result:='Form';
end;
function TFCEmbeddedFormModuleCreator.GetExisting: Boolean;
Begin
Result:=False;
end;
function TFCEmbeddedFormModuleCreator.GetFileSystem: String;
begin
Result := '';
end; //EROC itnA
function TFCEmbeddedFormModuleCreator.GetFormName: String;
begin
Result := '';
end;
function TFCEmbeddedFormModuleCreator.GetImplFileName: String;
Begin
Result:='';
end;
function TFCEmbeddedFormModuleCreator.GetIntfFileName: String;
Begin
Result:='';
end;
function TFCEmbeddedFormModuleCreator.GetMainForm: Boolean;
Begin
Result:=False;
end;
function TFCEmbeddedFormModuleCreator.GetOwner: IOTAModule;
var
ModuleServices: IOTAModuleServices;
Module: IOTAModule;
NewModule: IOTAModule;
Begin
Result:=Nil;
ModuleServices := BorlandIDEServices as IOTAModuleServices;
Module:=ModuleServices.CurrentModule;
If Module=Nil Then Exit;
If Module.QueryInterface(IOTAProject,NewModule)=0 Then
Result:=NewModule
Else
Begin
If Module.OwnerModuleCount>0 Then
Begin
NewModule:=Module.OwnerModules[0];
If (NewModule<>Nil) And (NewModule.QueryInterface(IOTAProject,Result)<>0)Then
Result:=Nil;
End;
End;
end;
function TFCEmbeddedFormModuleCreator.GetShowForm: Boolean;
Begin
Result:=True;
end;
function TFCEmbeddedFormModuleCreator.GetShowSource: Boolean;
Begin
Result:=True;
end;
function TFCEmbeddedFormModuleCreator.GetUnnamed: Boolean;
Begin
Result:=True;
end;
function TFCEmbeddedFormModuleCreator.NewFormFile(const FormIdent: String;
const AncestorIdent: String): IOTAFile;
Begin
Result:=Nil;
end;
function TFCEmbeddedFormModuleCreator.NewImplSource(const ModuleIdent: String;
const FormIdent: String;
const AncestorIdent: String): IOTAFile;
Begin
Result:=TFCEmbeddedFormSourceFile.Create(ImplSource(ModuleIdent,FormIdent,AncestorIdent));
end;
function TFCEmbeddedFormModuleCreator.NewIntfSource(const ModuleIdent: String;
const FormIdent: String;
const AncestorIdent: String): IOTAFile;
Begin
Result:=Nil;
end;
constructor TFCEmbeddedFormSourceFile.Create(const Source: String);
Begin
FSource:=Source;
end;
function TFCEmbeddedFormSourceFile.GetAge: TDateTime;
Begin
Result:=-1;
end;
function TFCEmbeddedFormSourceFile.GetSource: String;
Begin
Result:=FSource;
end;
{ TFCEmbeddedFormExpert }
function TFCEmbeddedFormExpert.GetName: string;
begin
Result := 'Embedded form';
end;
function TFCEmbeddedFormExpert.GetComment: string;
begin
Result := 'Creates a new TFCEmbeddedForm for embedding into a FormContainer';
end;
function TFCEmbeddedFormExpert.GetGlyph: Cardinal;
begin
Result := 0;
end;
function TFCEmbeddedFormExpert.GetState: TWizardState;
begin
Result := [];
end;
function TFCEmbeddedFormExpert.GetIDString: string;
begin
Result := 'BilleniumEffects.EmbeddedFormExpert';
end;
function TFCEmbeddedFormExpert.GetAuthor: string;
begin
Result := 'BilleniumSoft';
end;
function TFCEmbeddedFormExpert.GetPage: string;
begin
Result := 'New';
end;
procedure TFCEmbeddedFormExpert.Execute;
begin
ExecuteFCEmbeddedFormExpert;
end;
procedure ExecuteFCEmbeddedFormExpert;
begin
(BorlandIDEServices as IOTAModuleServices).CreateModule(TFCEmbeddedFormModuleCreator.Create);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -