看看下面代码,不明白发mail
liuyj@cbn.com.cn
unit UnitDownload;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, ExtCtrls;
Const
Down_Mpg = wm_User + 2;
type
TDownLoadThread = class(TThread)
private
{ Private declarations }
protected
procedure Execute; override;
end;
type
TFormDownload = class(TForm)
Panel1: TPanel;
Bevel2: TBevel;
GroupBox1: TGroupBox;
SingleLeaveTimeLabel: TLabel;
Image1: TImage;
SingleProgressBar: TProgressBar;
Button_Cancel: TButton;
Image9: TImage;
Label1: TLabel;
procedure FormShow(Sender: TObject);
procedure Button_CancelClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
procedure DownMpg(Var Msg:Tmessage); message Down_MPG;
{ Private declarations }
public
{ Public declarations }
end;
var
FormDownload: TFormDownload;
DownLoadThread : TDownLoadThread;
implementation
uses UnitConst, UnitContent;
{$R *.dfm}
procedure TDownLoadThread.Execute;
var
DownLoadHandle : HWND ;
begin
DownLoadHandle := FormDownLoad.Handle ;
StartSend := GetTickCount() ;
DllDown(@LoginNCUBE, 'VOD', PChar(Format('DOWN %s %s %s',[FormContent.ListViewMEDIA_FILENAME.Selected.SubItems[0], ModifyDirectory(Directory), SelectLPARTITION + FormContent.ListViewMEDIA_FILENAME.Selected.Caption])), DownLoadHandle);
FormDownLoad.Close;
end;
procedure TFormDownLoad.DownMpg(var Msg: TMessage);
var
LeaveTime : Int64;
Progress : Int64;
begin
if SingleProgressBar.Position = 99 then
begin
Close ;
end
else
begin
SingleProgressBar.StepIt ;
Progress := SingleProgressBar.Position ;
LeaveTime := SingleLeaveTime(StartSend, Progress) div 1000;
SingleLeaveTimeLabel.Caption := '剩余时间:' + IntToTime(LeaveTime);
end;
end;
procedure TFormDownload.FormShow(Sender: TObject);
begin
SingleLeaveTimeLabel.Caption := '' ;
SingleProgressBar.Position := 1 ;
DownLoadThread := TDownLoadThread.Create(False);
{if FontSize(Application.handle) = 120 then
begin
OldHeight := (Sender as TForm).Height;
OldWith := (Sender as TForm).Width;
(Sender as TForm).Height := Round((Sender as TForm).Height * 1.25 + 0.5);
(Sender as TForm).Width := Round((Sender as TForm).Width * 1.25 + 0.5);
end;}
end;
procedure TFormDownload.Button_CancelClick(Sender: TObject);
begin
Screen.Cursor := crHourGlass;
DownLoadThread.Suspend;
DownLoadThread.Terminate;
Close;
Screen.Cursor := crDefault;
end;
procedure TFormDownload.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
{if FontSize(Application.handle) = 120 then
begin
(Sender as TForm).Height := OldHeight;
(Sender as TForm).Width := OldWith;
end;}
end;
end.
谢谢