Activex调用打印机的问题?急~~~
hwy 2001-10-11 09:10:55 下面是一个ASP组件的代码,代码中只有一个方法show,相当简单,但我不明白哪里不对:
unit U_rr;
{$WARN SYMBOL_PLATFORM OFF}
interface
uses
ComObj, ActiveX, AspTlb, rr_TLB, Dialogs,StdVcl,printers,Graphics;
type
Trrshow = class(TASPObject, Irrshow)
protected
procedure OnEndPage; safecall;
procedure OnStartPage(const AScriptingContext: IUnknown); safecall;
procedure show; safecall;
end;
implementation
uses ComServ;
procedure Trrshow.OnEndPage;
begin
inherited OnEndPage;
end;
procedure Trrshow.OnStartPage(const AScriptingContext: IUnknown);
begin
inherited OnStartPage(AScriptingContext);
end;
procedure Trrshow.show;
begin
Response.Write('<h3>Delphi文本</h3>');
with Printer do
begin
BeginDoc;
Canvas.Textout(10, 10, '程序执行成功');
EndDoc;
end;
end;
initialization
TAutoObjectFactory.Create(ComServer, Trrshow, Class_rrshow,
ciMultiInstance, tmApartment);
end.
-------------------------
调用的脚本如下:(qqq.asp)
<HTML>
<BODY>
<TITLE> Testing Delphi ASP </TITLE>
<CENTER>
<H3> You should see the results of your Delphi Active Server method below </H3>
</CENTER>
<HR>
<% Set DelphiASPObj = Server.CreateObject("rr.rrshow")
DelphiASPObj.show
%>
<HR>
</BODY>
</HTML>
--------------
这样页面是打不开的,也就是说有错误,把WITH后的内容去掉,即成为这样:
procedure Trrshow.show;
begin
Response.Write('<h3>Delphi文本</h3>');
end;
是正确执行的,难道Activex不能调用打印机吗,这当然不可能,但问题在哪呢?
另外,为什么设断点时不能中断呢?我已经在Run->Param中设置过用IE执行qqq.asp。
补充:上述做法好象是不对的,ActiveX 和 ASP Object 差别很大,我现在用的是 ASP Object,可能后果是提交的同时就打印到服务器上,但我要求是在客户机上打印出来,那又应该用哪个呢?我用AutoMation object试过,好象也是不行。
用ActiveForm肯定是可以的,已实现过。
请高手指点一下吧!