delphi path login function parameters ie javascript
1.打开多个包含控件的页面出错
在delphi7中开发的控件就有这个问题,缘由出在自己开发环境的类库代码有问题。目前没有好的解决方法,官方给出过修改办法,我没有试验成功,使用delphi2007开发,到目前为止没有出现这类问题。java
2.资源的释放
重载Destroy; override;函数,在IE6.0中,关闭窗口会调用到这个函数。但我拿到IE7.0看的时候却不行了,只会在跳转到另外一个页面调用,直接点击IE右上角的关闭按钮时没用。
后来发现,点击关闭按钮时会产生“OnDestroy”事件,在它的调用代码中加入咱们用来释放的资源,如
procedure TActiveFormX.DestroyEvent(Sender: TObject);
begin
self.destroy_app();//用来释放资源
if FEvents <> nil then FEvents.OnDestroy;
end;
能够解决问题。web
3.调试
调试ActiveForm,不能直接点调试运行按钮,由于它不是一个可执行的程序。须要在这以前设定一下运行参数,在菜单run--parameters中“host application”设置ie程序的路径,通常为C:\Program Files\Internet Explorer\iexplore.exe,“parameters”设置包含控件的htm页的路径,如d:\finger\FingerProj1.htm,而后就能够设定断点开始调试。
还有一个地方须要注意,运行的时候ie会检测在C:\WINDOWS\Downloaded Program Files目录中是否已经有了该控件,若是有就会直接用该控件,新生成的控件不会被运行,因此最好在调试以前将C:\WINDOWS\Downloaded Program Files目录的该控件的旧有版本删除掉。安全
4.向javascript中传递事件
只能是以下形式
<script for="obj" event="onhello(arg)" language="jscript"></script>,“onhello”为事件名,arg为参数。
obj.onhello=function()
{}这种形式无效。服务器
5.去除控件在网页中的虚框
因为安全的缘由,默认状况下控件在页面中不能得到焦点,不能响应一些事件。解决的方法是使用document.write输出控件的标签代码。如:
function create_ck_webcamtest()
{
document.write("<OBJECT id='ct_webcamtest' classid='clsid:CCCC7A66-B886-47F3-A2CD-09793F65DD1B' ");
document.write("codebase='./twebcam.ocx' width=160 height=25 align=center hspace=0 vspace=0>");
document.write("</OBJECT>");
}app
6.压缩和签名
通常用delphi开发的控件比较大,只一个空白的ActiveForm就有500k左右。必须对它进行压缩,我用“aspack”,能够减小一半左右的大小,再能够打包成cab形似会更小。
签名也是必须的,否则IE会禁止控件的安装,使用微软提供的签名软件,前提是你要买一个证书,一年的费用1000多人民币。ide
7.将二进制文件传递给web服务器
//用户登录示例
function TActiveFormX.User_Login(shop_id: Integer;
const path: WideString): Integer;
var
IdHttp1:TIdHttp;
PostStream:TIdMultiPartFormDataStream;
ResponseStream:TIdStringStream;
ms:TMemoryStream;
login_path:string;
begin
result:=-1;函数
if not self.FIs_Scaned then
begin
result:=-11;
exit;
end;spa
login_path:=trim(string(path));
if login_path='' then
begin
result:=-12;
exit;
end;.net
IdHttp1:=TIdHttp.Create(nil);
PostStream:=TIdMultiPartFormDataStream.Create;
ResponseStream:=TIdStringStream.Create('');
ms:=TMemoryStream.Create;
try
ms.Write(self.fpimage.Bits^,self.fpimage.Width*self.fpimage.Height);
ms.Position:=0;
PostStream.AddFormField('shop_id',inttostr(shop_id));
PostStream.AddFormField('fp_w',inttostr(self.fpimage.Width));
PostStream.AddFormField('fp_h',inttostr(self.fpimage.Height));
PostStream.AddObject('File1','image/fp_bmp',ms,'fp.bp');
try
IdHttp1.Request.ContentType:=PostStream.RequestContentType;
IdHttp1.Post(login_path,PostStream,ResponseStream);
result:=strtoint(trim(ResponseStream.DataString));
except
result:=-13;
end;
finally
IdHttp1.Free;
PostStream.Free;
ms.Free;
ResponseStream.Free; end;end;