Delphi,isapi,中的TPageProducer类继承(100分)

  • 主题发起人 主题发起人 110
  • 开始时间 开始时间
1

110

Unregistered / Unconfirmed
GUEST, unregistred user!
我想动态创建TPageProducer,OnHTMLTag事件如何写和调用?谢谢
以前我写了一个动态创建TMenuItem的程序,如下:
var i:integer;
begin
for i:=0 to 3 do begin
subitem:=TMenuItem.create(self);
subitem.caption:='sdfgdfg';
subitem.onclick:=mypopup;
mainmenu.item[0]:=add(subitem);
end;
end;

procedure mypopup(sender:TObject);
begin
with sender as TMenuItem do begin
showmesssge(caption);
end;
end;
 
不一样,报错!
procedure PageProducerOutput1HTMLTag(Sender: TObject
Tag: TTag;
const TagString: String
TagParams: TStrings
var ReplaceText: String);
begin
case Tag of
tgCustom:
begin
if TagString = 'TitleInfo' then ReplaceText:='hello'
if TagString = 'Status' then ReplaceText:= 'boby';
if TagString = 'Messages' then ReplaceText:= 'dd;
end;
end;
end;

PageProducer := TPageProducer.Create(nil);
PageProducer.OnHTMLTag :=PageProducerOutput1HTMLTag;
^%^


 
声明一个TPageProducer一样的过程OnMyHTMLTag:
procedure OnMyHTMLTag(.....);
Begin
.......
end;
myPageProducer:=TPageProducer.create(application);
MyPageProducer.OnHTMLTag:=OnMyHTMLTag;
 
要放到一个类中.
procedure PageProducerOutput1HTMLTag(Sender: TObject
Tag: TTag;
const TagString: String
TagParams: TStrings
var ReplaceText: String);
 
李璋琦:我已经这样做啦,报错!
Incompatible types :method pointer and regular procedure
 
TYourClass=class(TObject)
{...}
procedure PageProducerOutput1HTMLTag(Sender: TObject
Tag: TTag;
const TagString: String
TagParams: TStrings
var ReplaceText: String);
end;


{....}
 
沈前卫:我已经这样声明啦!
 
沈前卫:工作量有点大,不过我我想问下原理可以吗?thank u
 
TPageHTML = class (TObject)
public
constructor Create()
overload;
destructor Destroy()
override;
procedure PageProducerOutputHTMLTag(Sender: TObject
Tag: TTag;
const TagString: String
TagParams: TStrings;
var ReplaceText: String);
end;

constructor TPageHTML.Create;
begin
inherited Create;

end;

destructor TPageHTML.Destroy;
begin
inherited Destroy;

end;

procedure TPageHTML.PageProducerOutputHTMLTag(Sender: TObject
Tag: TTag;
const TagString: String
TagParams: TStrings
var ReplaceText: String);
begin
case Tag of
tgCustom:
begin
if TagString = 'TitleInfo' then ReplaceText:='hello'
if TagString = 'Status' then ReplaceText:= 'boby';
if TagString = 'Messages' then ReplaceText:= 'sess';
end;
end;
end;


 
TPageHTML = class (TObject)
public
constructor Create()
overload;
destructor Destroy()
override;
procedure PageProducerOutputHTMLTag(Sender: TObject
Tag: TTag;
const TagString: String
TagParams: TStrings;
var ReplaceText: String);
end;

constructor TPageHTML.Create;
begin
inherited Create;

end;

destructor TPageHTML.Destroy;
begin
inherited Destroy;

end;

procedure TPageHTML.PageProducerOutputHTMLTag(Sender: TObject
Tag: TTag;
const TagString: String
TagParams: TStrings
var ReplaceText: String);
begin
case Tag of
tgCustom:
begin
if TagString = 'TitleInfo' then ReplaceText:='hello'
if TagString = 'Status' then ReplaceText:= 'boby';
if TagString = 'Messages' then ReplaceText:= 'sess';
end;
end;
end;



 

Similar threads

S
回复
0
查看
896
SUNSTONE的Delphi笔记
S
S
回复
0
查看
873
SUNSTONE的Delphi笔记
S
S
回复
0
查看
712
SUNSTONE的Delphi笔记
S
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
685
import
I
后退
顶部