S
sunweikey
Unregistered / Unconfirmed
GUEST, unregistred user!
我想自定义一个Form基类将其加入D7的IDE中
具体的UNIT代码如下:
unit MainForm;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
comctrls, dbtables, ExptIntf, ToolIntf, EditIntf,DesignIntf;
Type
TMainForm = class (TForm)
private
protected
public
constructor Create(Owner: TComponent); override;
published
end;
TMainFormExpert = class (TIExpert)
public
function GetStyle: TExpertStyle; override;
function GetName: string; override;
function GetAuthor: string; override;
function GetComment: string; override;
function GetPage: string; override;
function GetGlyph: HICON; override;
function GetState: TExpertState; override;
function GetIDString: string; override;
function GetMenuText: string; override;
procedure Execute; override;
end;
TwitMainExpert = class (TMainFormExpert) //project expert
public
function GetStyle: TExpertStyle; override;
function GetIDString: string; override;
function GetGlyph: HICON; override;
function GetPage: string; override;
end;
procedure Register;
implementation
constructor TMainForm.Create(Owner: TComponent);
var aBuff:array[0..255] of char;
begin
inherited Create(Owner);
Font.Size := 9;
Font.Charset:= DEFAULT_CHARSET;
Font.Name := 'Arial';
FormStyle := fsMDIForm;
strPCopy(aBuff,ExtractFileName(Application.ExeName));
end;
// "TChildExpert" project expert
function TMainFormExpert.GetStyle: TExpertStyle;
begin
Result := esStandard;
end;
function TMainFormExpert.GetName: string;
begin
Result := 'Main Form Wizard';
end;
function TMainFormExpert.GetAuthor: string;
begin
Result := 'Sun Weikey';
end;
function TMainFormExpert.GetComment: string; begin Result := 'TMainFormExpert Wizard'; end;
function TMainFormExpert.GetPage: string; begin Result := ''; end;
function TMainFormExpert.GetGlyph: HICON; begin Result := 0; end;
function TMainFormExpert.GetState: TExpertState; begin Result := [esEnabled]; end;
function TMainFormExpert.GetIDString: string; begin Result := 'WeikeyIT.MainFormWit'; end;
function TMainFormExpert.GetMenuText: string; begin Result := '&MainForm Wizard' end;
procedure TMainFormExpert.Execute;
var
ModuleName, FormName, FileName: string;
ModIntf: TIModuleInterface;
begin
ToolServices.GetNewModuleAndClassName('MainForm', ModuleName, FormName, FileName);
ModIntf := ToolServices.CreateModuleEx(FileName, FormName,'MainForm', '', nil, nil,
[cmNewForm, cmAddToProject, cmUnNamed]);
ModIntf.ShowSource;
ModIntf.ShowForm;
ModIntf.Release;
end;
// "TwitExpert" WeikeyIT expert
function TwitMainExpert.GetStyle: TExpertStyle; begin Result := esProject end;
function TwitMainExpert.GetIDString: string; begin Result := 'WeikeyIT.witMainForm' end;
function TwitMainExpert.GetPage: string; begin Result := 'WeikeyIT' end;
function TwitMainExpert.GetGlyph: HICON; begin Result := 0 end;
procedure Register;
begin
RegisterCustomModule(TMainForm,TCustomModule);
RegisterLibraryExpert(TMainFormExpert.Create);
RegisterLibraryExpert(TwitMainExpert.Create);
end;
end.
通过在Component菜单Install Component安装该单元文件,编译packages的时候提示
RegisterCustomModule(TMainForm,TCustomModule); 该句中的TCustomModule没声明
请我查看了该过程在DesignIntf单元中过程原形为
procedure RegisterCustomModule(ComponentBaseClass: TComponentClass;
CustomModuleClass: TCustomModuleClass);
begin
if Assigned(RegisterCustomModuleProc) then
RegisterCustomModuleProc(CurrentGroup, ComponentBaseClass,
CustomModuleClass);
end;
请告诉我我错在那里,该怎么修改?谢谢!
**在D7之前该UNIT可以安装!
具体的UNIT代码如下:
unit MainForm;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
comctrls, dbtables, ExptIntf, ToolIntf, EditIntf,DesignIntf;
Type
TMainForm = class (TForm)
private
protected
public
constructor Create(Owner: TComponent); override;
published
end;
TMainFormExpert = class (TIExpert)
public
function GetStyle: TExpertStyle; override;
function GetName: string; override;
function GetAuthor: string; override;
function GetComment: string; override;
function GetPage: string; override;
function GetGlyph: HICON; override;
function GetState: TExpertState; override;
function GetIDString: string; override;
function GetMenuText: string; override;
procedure Execute; override;
end;
TwitMainExpert = class (TMainFormExpert) //project expert
public
function GetStyle: TExpertStyle; override;
function GetIDString: string; override;
function GetGlyph: HICON; override;
function GetPage: string; override;
end;
procedure Register;
implementation
constructor TMainForm.Create(Owner: TComponent);
var aBuff:array[0..255] of char;
begin
inherited Create(Owner);
Font.Size := 9;
Font.Charset:= DEFAULT_CHARSET;
Font.Name := 'Arial';
FormStyle := fsMDIForm;
strPCopy(aBuff,ExtractFileName(Application.ExeName));
end;
// "TChildExpert" project expert
function TMainFormExpert.GetStyle: TExpertStyle;
begin
Result := esStandard;
end;
function TMainFormExpert.GetName: string;
begin
Result := 'Main Form Wizard';
end;
function TMainFormExpert.GetAuthor: string;
begin
Result := 'Sun Weikey';
end;
function TMainFormExpert.GetComment: string; begin Result := 'TMainFormExpert Wizard'; end;
function TMainFormExpert.GetPage: string; begin Result := ''; end;
function TMainFormExpert.GetGlyph: HICON; begin Result := 0; end;
function TMainFormExpert.GetState: TExpertState; begin Result := [esEnabled]; end;
function TMainFormExpert.GetIDString: string; begin Result := 'WeikeyIT.MainFormWit'; end;
function TMainFormExpert.GetMenuText: string; begin Result := '&MainForm Wizard' end;
procedure TMainFormExpert.Execute;
var
ModuleName, FormName, FileName: string;
ModIntf: TIModuleInterface;
begin
ToolServices.GetNewModuleAndClassName('MainForm', ModuleName, FormName, FileName);
ModIntf := ToolServices.CreateModuleEx(FileName, FormName,'MainForm', '', nil, nil,
[cmNewForm, cmAddToProject, cmUnNamed]);
ModIntf.ShowSource;
ModIntf.ShowForm;
ModIntf.Release;
end;
// "TwitExpert" WeikeyIT expert
function TwitMainExpert.GetStyle: TExpertStyle; begin Result := esProject end;
function TwitMainExpert.GetIDString: string; begin Result := 'WeikeyIT.witMainForm' end;
function TwitMainExpert.GetPage: string; begin Result := 'WeikeyIT' end;
function TwitMainExpert.GetGlyph: HICON; begin Result := 0 end;
procedure Register;
begin
RegisterCustomModule(TMainForm,TCustomModule);
RegisterLibraryExpert(TMainFormExpert.Create);
RegisterLibraryExpert(TwitMainExpert.Create);
end;
end.
通过在Component菜单Install Component安装该单元文件,编译packages的时候提示
RegisterCustomModule(TMainForm,TCustomModule); 该句中的TCustomModule没声明
请我查看了该过程在DesignIntf单元中过程原形为
procedure RegisterCustomModule(ComponentBaseClass: TComponentClass;
CustomModuleClass: TCustomModuleClass);
begin
if Assigned(RegisterCustomModuleProc) then
RegisterCustomModuleProc(CurrentGroup, ComponentBaseClass,
CustomModuleClass);
end;
请告诉我我错在那里,该怎么修改?谢谢!
**在D7之前该UNIT可以安装!