D10DJkaimengwenshang/public10/design/U_FormInitThread.pas
DESKTOP-E401PHE\Administrator 74d01e92e1 ~
2025-09-27 14:24:10 +08:00

69 lines
1.9 KiB
ObjectPascal
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

unit U_FormInitThread;
interface
uses
Classes, SysUtils, Forms,U_WindowFormdesign,Messages,Data.DB,Data.Win.ADODB;
type
TFormInitThread = class(TThread)
private
fWindowDesign: TWindowFormdesign; // 替换为你的数据模块类型
fForm:Tform;
fFormId:integer;
fADOTmp: TADOQuery;
fADOQCmd: TADOQuery;
fWhichFun:String;
procedure LoadData;
protected
procedure Execute; override;
public
constructor Create( mWindowDesign: TWindowFormdesign;mForm: Tform; mFormId: integer; ADOTmp: TADOQuery; ADOQCmd: TADOQuery;mWhichFun:String);
end;
implementation
constructor TFormInitThread.Create(mWindowDesign: TWindowFormdesign;mForm: Tform; mFormId: integer; ADOTmp: TADOQuery; ADOQCmd: TADOQuery;mWhichFun:String);
begin
inherited Create(False);
fWindowDesign := mWindowDesign;
fForm:= mForm ;
fFormId:=mFormId;
fADOTmp:= ADOTmp ;
fADOQCmd:= ADOQCmd ;
fWhichFun:= mWhichFun ;
FreeOnTerminate := True; // 线程终止时自动释放
end;
procedure TFormInitThread.Execute;
var
i:integer;
begin
// 在这里执行耗时的数据加载操作
Synchronize(LoadData); // 使用 Synchronize 方法确保在主线程中更新 UI
//LoadData();
end;
procedure TFormInitThread.LoadData;
var
I: Integer;
begin
// 这里是实际加载数据的代码
// 假设你有一个方法叫 LoadDataFromDatabase 在数据模块中
if fWhichFun='' then
fWindowDesign.FormStyleInit1(fForm, fFormId, fADOTmp, fADOQCmd, '', '')
else
fWindowDesign.FormStyleInit(fForm, fFormId, fADOTmp, fADOQCmd, '', '');
// showMessage('44');
// for I := 0 to 10000000000 do
// begin
// if I=1000000000 then
// begin
// application.MessageBox(pchar('444'),'',0);
// end;
//end;
// 如果需要更新 UI可以在这里做因为 Synchronize 保证了它在主线程中执行
// 例如YourForm.YourControl.Caption := 'Data Loaded';
// 注意:确保 YourForm 和 YourControl 在此上下文中是有效的,或者通过其他方式传递引用
end;
end.