本文整理自网络,侵删。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
IdHTTP;
const
WM_WebUpdate = WM_USER + 1000;
type
TForm1 = class(TForm)
btn1: TButton;
mmo1: TMemo;
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure WMWebUpdate(var AMessage: TMessage); message WM_WebUpdate;
end;
TMyThread = class(TThread)
private
FRunType: Integer;
procedure Procedure0;
procedure Procedure1;
protected
procedure Execute; override;
public
property RunType: Integer read FRunType write FRunType;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TMyThread }
procedure TMyThread.Execute;
begin
inherited;
case FRunType of
0: Procedure0;
1: Procedure1;
end;
end;
procedure TMyThread.Procedure0;
var
IDHttp: TIdHTTP;
sWeb: string;
begin
IDHttp := TIdHTTP.Create(nil);
try
sWeb := IDHttp.Get('http://topic.csdn.net/u/20100409/13/fec3bb35-2dc2-431a-950e-c8f20e8b44c8.html?6345');
SendMessage(Form1.Handle, WM_WebUpdate, Integer(PChar(sWeb)), 0);
finally
IDHttp.Free;
end;
end;
procedure TMyThread.Procedure1;
begin
//类别1执行代码
end;
procedure TForm1.btn1Click(Sender: TObject);
var
MyThread0, MyThread1: TMyThread;
begin
MyThread0 := TMyThread.Create(True);
MyThread0.FreeOnTerminate := True;
MyThread0.RunType := 0;
MyThread0.Resume;
MyThread1 := TMyThread.Create(True);
MyThread1.FreeOnTerminate := True;
MyThread1.RunType := 1;
MyThread1.Resume;
end;
procedure TForm1.WMWebUpdate(var AMessage: TMessage);
var
pWeb: PChar;
begin
pWeb := PChar(AMessage.WParam);
mmo1.Lines.Add(pWeb);
end;
end.
相关阅读 >>
Delphi hook 指定程序窗体和控件的 wndproc
Delphi api: setwindowpos改变窗口的位置与状态
Delphi dcc64.exe Delphi64位命令行编译器揭秘
Delphi dbexpress的upwherekeyonly的使用注意事项
更多相关阅读请进入《Delphi》频道 >>