执行老有错误,请指导啊。只有100分,全部奉上!
*********************************************************************
*********************************************************************
unit self_tthread_weber;interfaceuses
Classes
, ShDocVw //webbrowser
,MSHTML //IHtmlDocument2
,SysUtils //strtoint
,prog //全局变量
,self_forum //login type
,self_tthread_check //检测
;
type
tthread_weber = class(TThread)
private
{ Private declarations }
owner:tcomponent;
weber:twebbrowser;
urlstr:string;
Fthreadcheck:tthread_check;
protected
procedure Execute; override;
public
constructor Create(aowner:tcomponent;url:string;suspend:boolean);
//distructor
procedure weberdocComplete(Sender: TObject;const pDisp: IDispatch; var URL: OleVariant);
end;implementation{ Important: Methods and properties of objects in visual components can only be
used in a method called using Synchronize, for example, Synchronize(UpdateCaption); and UpdateCaption could look like, procedure tthread_weber.UpdateCaption;
begin
Form1.Caption := 'Updated in a thread';
end; }{ tthread_weber }procedure tthread_weber.Execute;
begin
{ Place thread code here }
Fthreadcheck.Resume;
Fthreadcheck.WaitFor;
end;/////public
constructor tthread_weber.Create(aowner:tcomponent;url:string;suspend:boolean);
begin
owner:=aowner;
urlstr:=url;
weber:=twebbrowser.Create(aowner);
//aowner.InsertControl(weber);
weber.Navigate(url);
Fthreadcheck:=tthread_check.create(weber.Tag,2002,8000,true);
weber.OnDocumentComplete:=weberdoccomplete;
end;
////////////////////////////////////
procedure tthread_weber.weberdocComplete(Sender: TObject;const pDisp: IDispatch; var URL: OleVariant);
{
var
listtmp:tstrings;
lineindex:integer;
}
begin
{
listtmp:=tstringlist.create;
listtmp.Add(IHtmlDocument2(Weber.Document).Body.OuterText);
listtmp.SaveToFile(exeinfo.tempfile);
listtmp.loadfromFile(exeinfo.tempfile);
if listtmp.Strings[0]='y' then
begin
dz.setlogined(loginyes);
dz.setusername(listtmp.Strings[1]);
dz.setuid(strtoint(trim(listtmp.Strings[2])));
end
else
begin
dz.setlogined(loginno);
end;
deletefile(pchar(exeinfo.tempfile));
listtmp.free;
}
weber.Tag:=2002;
end;
end.
*********************************************************************
*********************************************************************
unit self_tthread_check;
interfaceuses
Classes
, ShDocVw //webbrowser
,MSHTML //IHtmlDocument2
,SysUtils //strtoint
,prog //全局变量
,self_forum //set login
,Dialogs //showmessage;
;type
tthread_check = class(TThread)
private
{ Private declarations }
ex:integer;
value:integer;
timeout:integer;
protected
procedure Execute; override;
public
constructor Create(express:integer;pvalue:integer;ptimeout:integer;suspend:boolean);
end;implementation{ Important: Methods and properties of objects in visual components can only be
used in a method called using Synchronize, for example, Synchronize(UpdateCaption); and UpdateCaption could look like, procedure tthreadweber.UpdateCaption;
begin
Form1.Caption := 'Updated in a thread';
end; }{ tthreadweber }procedure tthread_check.Execute;
var
times:integer;
begin
{ Place thread code here }
//showmessage('thread start');
times:=0;
self.ReturnValue:=1;
while(ex<>value) and (times<timeout) do
begin
sleep(1000);
times:=times+1000;
end;
end;
constructor tthread_check.Create(express:integer;pvalue:integer;ptimeout:integer;suspend:boolean);
begin
inherited Create(true);
EX:=EXPRESS;
value:=pvalue;
FreeOnTerminate:=true;
timeout:=ptimeout;
if not suspend then resume; end;
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
end.
*********************************************************************
*********************************************************************
unit self_tthread_weber;interfaceuses
Classes
, ShDocVw //webbrowser
,MSHTML //IHtmlDocument2
,SysUtils //strtoint
,prog //全局变量
,self_forum //login type
,self_tthread_check //检测
;
type
tthread_weber = class(TThread)
private
{ Private declarations }
owner:tcomponent;
weber:twebbrowser;
urlstr:string;
Fthreadcheck:tthread_check;
protected
procedure Execute; override;
public
constructor Create(aowner:tcomponent;url:string;suspend:boolean);
//distructor
procedure weberdocComplete(Sender: TObject;const pDisp: IDispatch; var URL: OleVariant);
end;implementation{ Important: Methods and properties of objects in visual components can only be
used in a method called using Synchronize, for example, Synchronize(UpdateCaption); and UpdateCaption could look like, procedure tthread_weber.UpdateCaption;
begin
Form1.Caption := 'Updated in a thread';
end; }{ tthread_weber }procedure tthread_weber.Execute;
begin
{ Place thread code here }
Fthreadcheck.Resume;
Fthreadcheck.WaitFor;
end;/////public
constructor tthread_weber.Create(aowner:tcomponent;url:string;suspend:boolean);
begin
owner:=aowner;
urlstr:=url;
weber:=twebbrowser.Create(aowner);
//aowner.InsertControl(weber);
weber.Navigate(url);
Fthreadcheck:=tthread_check.create(weber.Tag,2002,8000,true);
weber.OnDocumentComplete:=weberdoccomplete;
end;
////////////////////////////////////
procedure tthread_weber.weberdocComplete(Sender: TObject;const pDisp: IDispatch; var URL: OleVariant);
{
var
listtmp:tstrings;
lineindex:integer;
}
begin
{
listtmp:=tstringlist.create;
listtmp.Add(IHtmlDocument2(Weber.Document).Body.OuterText);
listtmp.SaveToFile(exeinfo.tempfile);
listtmp.loadfromFile(exeinfo.tempfile);
if listtmp.Strings[0]='y' then
begin
dz.setlogined(loginyes);
dz.setusername(listtmp.Strings[1]);
dz.setuid(strtoint(trim(listtmp.Strings[2])));
end
else
begin
dz.setlogined(loginno);
end;
deletefile(pchar(exeinfo.tempfile));
listtmp.free;
}
weber.Tag:=2002;
end;
end.
*********************************************************************
*********************************************************************
unit self_tthread_check;
interfaceuses
Classes
, ShDocVw //webbrowser
,MSHTML //IHtmlDocument2
,SysUtils //strtoint
,prog //全局变量
,self_forum //set login
,Dialogs //showmessage;
;type
tthread_check = class(TThread)
private
{ Private declarations }
ex:integer;
value:integer;
timeout:integer;
protected
procedure Execute; override;
public
constructor Create(express:integer;pvalue:integer;ptimeout:integer;suspend:boolean);
end;implementation{ Important: Methods and properties of objects in visual components can only be
used in a method called using Synchronize, for example, Synchronize(UpdateCaption); and UpdateCaption could look like, procedure tthreadweber.UpdateCaption;
begin
Form1.Caption := 'Updated in a thread';
end; }{ tthreadweber }procedure tthread_check.Execute;
var
times:integer;
begin
{ Place thread code here }
//showmessage('thread start');
times:=0;
self.ReturnValue:=1;
while(ex<>value) and (times<timeout) do
begin
sleep(1000);
times:=times+1000;
end;
end;
constructor tthread_check.Create(express:integer;pvalue:integer;ptimeout:integer;suspend:boolean);
begin
inherited Create(true);
EX:=EXPRESS;
value:=pvalue;
FreeOnTerminate:=true;
timeout:=ptimeout;
if not suspend then resume; end;
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
end.
解决方案 »
- (求助)关于AlphaControls设置中文语言的问题
- delphi 特殊字符怎么在代码里显示???
- delphi clientsocket与serversocket问题
- 请问如何判断TCPExecute里面传来的是HTTP命令,TCP监听:17700端口,比如地址栏访问127.0.0.1:17700,那么在TCPExecute里面如何判断是HTTP的访问呢?
- 兄弟们救命了!!!!找视频控件
- Delphi+Excle简单问题请教大家。
- 急:如何做一个项目!!
- 关于函数返回值的问题?
- 现有成套成熟GPS、GIS软件技术,如有需要请进!!!!!!!!
- 怎么取Edit1.Text中的左边第一个字符
- 提问,用delphi编写判断十六制位数?
- 一奇怪的问题.!不清楚什么意思.!
修改fthread_check.FreeOnTerminate:=true;之后没有报错了,但是weberdocComplete始终不被执行,(webbrowser的ondocumentcomplete事件处理)
/////////////////////////////////////////////////////////////
//修改后的程序:
////////////////////////////////////////////////////////////
unit self_tthread_weber;interfaceuses
Classes
, ShDocVw //webbrowser
,MSHTML //IHtmlDocument2
,SysUtils //strtoint
,prog //全局变量
,self_forum //login type
,self_tthread_check //检测
,dialogs
;
type
tthread_weber = class(TThread)
private
{ Private declarations }
owner:tcomponent;
weber:twebbrowser;
urlstr:string;
Fthreadcheck:tthread_check;
protected
procedure Execute; override;
public
constructor Create(aowner:tcomponent;url:string;suspend:boolean);
//distructor
procedure weberdocComplete(Sender: TObject;const pDisp: IDispatch; var URL: OleVariant);
end;implementation{ Important: Methods and properties of objects in visual components can only be
used in a method called using Synchronize, for example, Synchronize(UpdateCaption); and UpdateCaption could look like, procedure tthread_weber.UpdateCaption;
begin
Form1.Caption := 'Updated in a thread';
end; }{ tthread_weber }procedure tthread_weber.Execute;
begin
{ Place thread code here }
Fthreadcheck.Resume;
Fthreadcheck.WaitFor;
Fthreadcheck.Free;
// self.DoTerminate;
end;/////public
constructor tthread_weber.Create(aowner:tcomponent;url:string;suspend:boolean);
begin
inherited Create(true);
owner:=aowner;
urlstr:=url;
weber:=twebbrowser.Create(aowner);
//aowner.InsertControl(weber);
weber.Navigate(url);
Fthreadcheck:=tthread_check.create(weber.Tag,2002,8000,true);
weber.OnDocumentComplete:=weberdoccomplete;
if not suspend then resume;
end;
////////////////////////////////////
procedure tthread_weber.weberdocComplete(Sender: TObject;const pDisp: IDispatch; var URL: OleVariant);
var
listtmp:tstrings;
lineindex:integer;begin
showmessage('in weberdoccomplte!');
listtmp:=tstringlist.create;
listtmp.Add(IHtmlDocument2(Weber.Document).Body.OuterText);
listtmp.SaveToFile(exeinfo.tempfile);
listtmp.loadfromFile(exeinfo.tempfile);
if listtmp.Strings[0]='y' then
begin
dz.setlogined(loginyes);
dz.setusername(listtmp.Strings[1]);
dz.setuid(strtoint(trim(listtmp.Strings[2])));
end
else
begin
dz.setlogined(loginno);
end;
deletefile(pchar(exeinfo.tempfile));
listtmp.free; weber.Tag:=2002;
end;
end.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
unit self_tthread_check;
interfaceuses
Classes
, ShDocVw //webbrowser
,MSHTML //IHtmlDocument2
,SysUtils //strtoint
,prog //全局变量
,self_forum //set login
,Dialogs //showmessage;
;type
tthread_check = class(TThread)
private
{ Private declarations }
ex:integer;
value:integer;
timeout:integer;
protected
procedure Execute; override;
public
constructor Create(express:integer;pvalue:integer;ptimeout:integer;suspend:boolean);
end;implementation{ Important: Methods and properties of objects in visual components can only be
used in a method called using Synchronize, for example, Synchronize(UpdateCaption); and UpdateCaption could look like, procedure tthreadweber.UpdateCaption;
begin
Form1.Caption := 'Updated in a thread';
end; }{ tthreadweber }procedure tthread_check.Execute;
var
times:integer;
begin
{ Place thread code here }
//showmessage('thread start');
times:=0;
self.ReturnValue:=1;
while(ex<>value) and (times<timeout) do
begin
sleep(1000);
times:=times+1000;
end;
self.FreeOnTerminate:=false;
end;
constructor tthread_check.Create(express:integer;pvalue:integer;ptimeout:integer;suspend:boolean);
begin
inherited Create(true);
EX:=EXPRESS;
value:=pvalue;
FreeOnTerminate:=true;
timeout:=ptimeout;
if not suspend then resume; end;end.