C:\Program Files\Borland\Delphi5\Help\example\Prgrsbar\pg1.pas
里面不是有使用的例子吗?
里面不是有使用的例子吗?
解决方案 »
- 调用WebService时,出现服务器未能识别HTTP头的错误怎么解决?
- 非常有挑战性的问题,提高时实刷新速度
- treeview如何让他在当前位置下移,急呀
- 简单问题:如何创建全局对象?
- 大师们!adoquery的查询结果另存为文件 给些方法!!!!
- 我使用TDBRichEdit控件,老出现“DataSet not in Edit or Insert mode”的异常。
- 安装ehlib 2.5
- sql explorer连接老版本oracle的问题
- 新春大吉,在此向各位拜年!
- 在注册表中怎么算出一个主键里有多少个项目?
- 请问各位大虾可否告之如何在webbrower里显示当前的链接地址吗?
- 一个目前无人能解答的问题
ProgressBar.Max := 100;if ProgressBar.Pregress < 100 then
ProgressBar.Progress := ProgressBar.Progress + 1
else
ProgressBar.Progress := 0;
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls, StdCtrls, Psock, NMHttp, ExtCtrls, jpeg;type
TForm1 = class(TForm)
NMHTTP1: TNMHTTP;
Button1: TButton;
Label1: TLabel;
edtURL: TEdit;
StatusBar1: TStatusBar;
Label2: TLabel;
lblTemp: TLabel;
Label4: TLabel;
lblFinal: TLabel;
ProgressBar1: TProgressBar;
procedure Button1Click(Sender: TObject);
procedure NMHTTP1Success(Cmd: CmdType);
procedure NMHTTP1PacketRecvd(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
begin
NMHTTP1.Get(edtURL.text);
end;procedure TForm1.NMHTTP1Success(Cmd: CmdType);
var
fname:string;
buf:string;
pnewfile,poldfile:pchar;
i:integer;
begin
{ Copyright (C) Bowman }
{ [email protected] }
//retrive the tmp file
fname:=nmhttp1.body;
//retrive file name
for i:=length(edtURL.Text) downto 1 do
if edtURL.text[i]<>'/' then
buf:=edtURL.text[i]+buf
else
break;
//assign file name
Getmem(poldFile,length(fname)+1);
StrPCopy(poldFile,fname);
Getmem(pnewfile,length(buf)+1);
StrPCopy(pnewfile,buf);
//rename it
MoveFile(poldfile,pnewfile);
Freemem(poldfile);
Freemem(pnewfile);
//show infomation
statusbar1.Panels.Items[0].text:='download complete';
lblTemp.caption:= fname;
lblFinal.Caption:=buf;
end;procedure TForm1.NMHTTP1PacketRecvd(Sender: TObject);
begin
//show progress
ProgressBar1.Position :=
Round( NMHTTP1.BytesRecvd /NMHTTP1.BytesTotal)*100;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
//init progress
ProgressBar1.Min:=0;
ProgressBar1.Max:=100;
ProgressBar1.Position:=0;
//NMHTTP property
//store in file
NMHTTP1.InputFileMode:= TRUE;
NMHTTP1.TimeOut:=2000;
//set temp file name
NMHTTP1.Body:='Part.tmp';
NMHTTP1.Header:='Head.tmp';
end;end.