在该程序执行的过程中,如果要关闭程序,请问我应该怎样操作?procedure TForm1.Button5Click(Sender: TObject);
var
j:integer;
begin
for j :=0 to 7 do
begin
button1.onclick(button1);
Delay(1000);
end;
end;如果直接关闭应用程序的话,程序要等循环终止才能关闭。我现在想在中途直接关闭程序。
解决方案 »
- 改版改乱了,搜不到了,只好弱弱的问一下各位了,数据转换的问题,参与就有分,强烈要求改回原版!
- 如何找到多媒体设备问题,如mtp设备,数码相机等通过usb接口连接的设备
- 为什么不能显示当前位置的中文内容???
- 高分调查!你正在使用Delphi2005吗?(一周后结贴,每日置顶)
- 控制word问题2
- 100 分:DELPHI5+ADO 操作数据时的一个问题,不知道是否是BUG
- Delphi 中怎么做托盘????
- 关于报表的几个问题。
- 怎么载入网络图片
- 关于SOCKETS
- (800分)求Bold for Delphi R4.0的license
- TQuery的Database属性是只读的,必须直接配置别名,那还有TDataBase控件有什么用
procedure TForm1.Button5Click(Sender: TObject);
var
j:integer;
begin
for j :=0 to 7 do
if b then
Delay(1000);
else Application.Terminater ;
Application.ProcessMessages ;
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
b := False ;
end;
线程怎么用?谢谢!
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,UThTest;type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
tt : TTest ;implementation
{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
tt := TTest.Create(False);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
TTest(tt).Terminate ;
Caption := 'end ' ;
end;
end.-----------------------------------------------unit UThTest;interfaceuses
windows,
Classes;type
TTest = class(TThread)
private
{ Private declarations }
protected
procedure Execute; override;
end;implementation{ Important: Methods and properties of objects in VCL or CLX can only be used
in a method called using Synchronize, for example, Synchronize(UpdateCaption); and UpdateCaption could look like, procedure TTest.UpdateCaption;
begin
Form1.Caption := 'Updated in a thread';
end; }{ TTest }uses Unit1 ;procedure TTest.Execute;
begin
{ Place thread code here }
while not Terminated do Sleep(100000000) ;
end;end.
begin
TerminateThread(TTest(tt).Handle,0);
TTest(tt).Free ;
Caption := 'end ' ;
end;
begin
TerminateThread(TTest(tt).Handle,0);
TTest(tt).Free ;
Caption := 'end ' ;
end;抱歉:)