用delphi做了一个小程序,就是简单的拷贝数据,为什么拷贝过去的很多乱码啊!?(拷贝的是txt文件)
程序是这样的:typeTForm1=class(TForm)ProgressBar1:TProgressBar;RichEdit1:TRichEdit;RichEdit2...
程序是这样的:
type
TForm1 = class(TForm)
ProgressBar1: TProgressBar;
RichEdit1: TRichEdit;
RichEdit2: TRichEdit;
Image1: TImage;
Label1: TLabel;
Button1: TButton;
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
len: integer;
i: integer=0;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject); //创建表单并装载文件
begin
richedit1.Lines.LoadFromFile('c:\wo.txt');
len:=length(richedit1.Text);
end;
procedure TForm1.Button1Click(Sender: TObject);//开始拷贝数据
begin
progressbar1.Position:=0;
richedit2.Lines.Clear;
timer1.Enabled:=true; //激活定时器
label1.Left:=30;
label1.Caption:='正在拷贝数据,请稍等。。。';
label1.Visible:=true;
i:=0;
end;
procedure TForm1.Timer1Timer(Sender: TObject); //激活定时器
var
part_len:integer;
begin
part_len:=len div 20;
richedit2.Text:=richedit2.Text+copy(richedit1.Text,i,part_len);
i:=i+part_len;
progressbar1.Position:=progressbar1.Position+1;
if i>len then
begin
timer1.Enabled:=false;
label1.Left:=100;
label1.Caption:='数据拷贝完成';
end;
end;
end. 展开
type
TForm1 = class(TForm)
ProgressBar1: TProgressBar;
RichEdit1: TRichEdit;
RichEdit2: TRichEdit;
Image1: TImage;
Label1: TLabel;
Button1: TButton;
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
len: integer;
i: integer=0;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject); //创建表单并装载文件
begin
richedit1.Lines.LoadFromFile('c:\wo.txt');
len:=length(richedit1.Text);
end;
procedure TForm1.Button1Click(Sender: TObject);//开始拷贝数据
begin
progressbar1.Position:=0;
richedit2.Lines.Clear;
timer1.Enabled:=true; //激活定时器
label1.Left:=30;
label1.Caption:='正在拷贝数据,请稍等。。。';
label1.Visible:=true;
i:=0;
end;
procedure TForm1.Timer1Timer(Sender: TObject); //激活定时器
var
part_len:integer;
begin
part_len:=len div 20;
richedit2.Text:=richedit2.Text+copy(richedit1.Text,i,part_len);
i:=i+part_len;
progressbar1.Position:=progressbar1.Position+1;
if i>len then
begin
timer1.Enabled:=false;
label1.Left:=100;
label1.Caption:='数据拷贝完成';
end;
end;
end. 展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询