admin 管理员组文章数量: 887021
2024年1月18日发(作者:程序设计语言怎么弄)
4.定义调整进度条位置的过程 (4. Define the procedure to adjust the progress bar position)This procedure will receive the messages from the progress thread.此过程将从进度线程接收消息。type
TForm1 = class(TForm) ProgressBar1: TProgressBar; private procedure UpdateProgressBar(aProgress: Integer); end;
procedure ProgressBar(aProgress: Integer);begin on := aProgress; ; // Make sure to repaint the progressbarend;5.从表单启动线程 (5. Start a thread from the form)This starts the progress thread这将启动进度线程type TForm1 = class(TForm) btnStart: TButton; procedure btnStartClick(Sender: TObject); private fMyThread: TMyThread; end;
procedure rtClick(Sender: TObject);begin if not Assigned(fMyThread) then
fMyThread := (UpdateProgressbar);end;6.完整的代码 (6. Complete code)Here is a copy of the complete unit这是完整单元的副本unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ComCtrls, StdCtrls;
type TProgressProc = procedure (aProgress: Integer) of object; // 0 to 100
TProgressThread = class(TThread) private FProgressProc: TProgressProc; FProgressValue: integer; procedure SynchedProgress; protected procedure Progress(aProgress: integer); virtual; public constructor Create(aProgressProc: TProgressProc; CreateSuspended: Boolean = False); reintroduce; virtual; end;
TMyThread = class(TProgressThread) protected
delphi 线程创建线程
版权声明:本文标题:delphi线程创建线程_在Delphi中以线程的形式显示主要进度 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.freenas.com.cn/jishu/1705575367h490631.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论