unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
type
TNumthread = class(TThread)
private
{ Private declarations }
protected
procedure Execute; override;
public
Tag:Integer;
Suffix:String;
LoadFirst:Integer;
Can:Boolean;
Procedure AddPicToBit;
Procedure EveryPicToBit(Index:Integer);
end;
var
Form1: TForm1;
loadThread:TNumthread;
implementation{$R *.dfm}
procedure Tnumthread.Execute;
begin
AddPicToBit;
end;
Procedure TNumThread.AddPicToBit;
begin
EveryPicToBit(tag);
end;
Procedure TNumThread.EveryPicToBit(Index:Integer);
begin
form1.Caption :=inttostr(index);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
loadthread:=Tnumthread.Create(True);
loadthread.Tag:=5;
loadthread.Resume;
end;end.
另外我在另一个程序中窗体Picform.pas中用同样的线程,用到窗体变量就换错,不知道什么原因
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
type
TNumthread = class(TThread)
private
{ Private declarations }
protected
procedure Execute; override;
public
Tag:Integer;
Suffix:String;
LoadFirst:Integer;
Can:Boolean;
Procedure AddPicToBit;
Procedure EveryPicToBit(Index:Integer);
end;
var
Form1: TForm1;
loadThread:TNumthread;
implementation{$R *.dfm}
procedure Tnumthread.Execute;
begin
AddPicToBit;
end;
Procedure TNumThread.AddPicToBit;
begin
EveryPicToBit(tag);
end;
Procedure TNumThread.EveryPicToBit(Index:Integer);
begin
form1.Caption :=inttostr(index);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
loadthread:=Tnumthread.Create(True);
loadthread.Tag:=5;
loadthread.Resume;
end;end.
另外我在另一个程序中窗体Picform.pas中用同样的线程,用到窗体变量就换错,不知道什么原因
解决方案 »
- 如何将任何文件类型数据保存到数据库中
- 关于菜单按键有效,但它的ShortCut键却失效的问题。 S.F.(吃青春饭的) 看到请进来
- 急!DBGrid 显示的Table的列(Column)的列宽怎么跟整个DBGrid的宽度一样?
- 制作AXTIVEX的问题(内存互相覆盖)
- 用delphi连接oracle数据库的步骤怎样?请高手赐教!!
- 在线等,我用SQL Server ADO 如何联接*.db的数据库?
- 怎样得到一个字符串string的子串 急~~~
- 如何才能实现小于1毫秒的定时器?
- 请教delphi中截取字符串的函数?
- 程序员的惊险恐怖片————不可能任务
- 有关截获系统错误信息,执行自定义的函数...在线请指教。
- dbchart问题,大家帮忙想想办法
{ 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 A.UpdateCaption;
begin
Form1.Caption := 'Updated in a thread';
end; }
procedure Tnumthread.Execute;
begin
Synchronize(AddPicToBit);
end;