在delhpi7中专家模版中追加自定义FORM的问题

sunweikey 2007-06-29 05:05:21
我想自定义一个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可以安装!
...全文
155 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
sunweikey 2007-06-29
  • 打赏
  • 举报
回复
难道没有人知道?
只有想设置一个基类,在每个FORM的USE里家上该FORM,不能进行继承吗?

5,386

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧