在delhpi7中专家模版中追加自定义FORM的问题
我想自定义一个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可以安装!
...全文
相关推荐
delhpi做的闰年判断器
主程序(Form):定义程序的主窗口和控件,编写事件处理代码。**五、调试与优化**对于描述中提到的“不好用”,可能是由于以下原因:1. 用户输入验证不足,导致无效年份输入。2.
第一节 Form窗体间的参数传递[基础学习]
7.
TButton增加OnMouseLeave事件Delphi源码
在Delphi编程环境中,我们经常会遇到需要自定义控件行为的情况。
一个基于窗体的Delphi登录跳转程序..rar
如果验证成功,程序可能会使用Form.Show或者Form2.Show方法来显示新的窗体,实现界面跳转。
用Delphi实现Web Service的简单示例
在www.pudn.com.txt和WebSerivies这两个文件中,可能包含了更详细的步骤、代码示例或者遇到问题的解决方案。


