delphi等待动画
<p>delphi等待动画</p><p>首先要在网上下载等待的GIF文件。</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 0, 1)">unit wait;
</span><span style="color: rgba(128, 128, 128, 1)">///</span> <span style="color: rgba(128, 128, 128, 1)"><author></span><span style="color: rgba(0, 128, 0, 1)">cxg 2022-8-12</span><span style="color: rgba(128, 128, 128, 1)"></author></span>
<span style="color: rgba(0, 0, 255, 1)">interface</span><span style="color: rgba(0, 0, 0, 1)">
uses
Vcl.Imaging.GIFImg,System.SysUtils,
Vcl.Graphics, Vcl.Controls, forms,
Vcl.ExtCtrls, Vcl.StdCtrls;
function playWait(own: TForm): TPanel;
procedure stopWait(pnl: TPanel);
implementation
function playWait(own: TForm): TPanel;
begin
</span><span style="color: rgba(0, 0, 255, 1)">var</span> pnl: TPanel :=<span style="color: rgba(0, 0, 0, 1)"> TPanel.Create(own);
pnl.BevelOuter :</span>=<span style="color: rgba(0, 0, 0, 1)"> bvNone;
pnl.Parent :</span>=<span style="color: rgba(0, 0, 0, 1)"> own;
pnl.AutoSize :</span>=<span style="color: rgba(0, 0, 0, 1)"> True;
pnl.Left :</span>= Screen.Width div <span style="color: rgba(128, 0, 128, 1)">2</span><span style="color: rgba(0, 0, 0, 1)">;
pnl.Top :</span>= Screen.Height div <span style="color: rgba(128, 0, 128, 1)">2</span> - <span style="color: rgba(128, 0, 128, 1)">150</span><span style="color: rgba(0, 0, 0, 1)">;
pnl.Show;
</span><span style="color: rgba(0, 0, 255, 1)">var</span> img: TImage :=<span style="color: rgba(0, 0, 0, 1)"> TImage.Create(pnl);
img.Parent :</span>=<span style="color: rgba(0, 0, 0, 1)"> pnl;
img.Stretch :</span>= <span style="color: rgba(0, 0, 255, 1)">true</span><span style="color: rgba(0, 0, 0, 1)">;
img.AutoSize :</span>=<span style="color: rgba(0, 0, 0, 1)"> True;
img.Picture.LoadFromFile(ExtractFilePath(Application.ExeName) </span>+ <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">1.gif</span><span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(0, 0, 0, 1)">);
TGIFImage(img.Picture.Graphic).Animate :</span>=<span style="color: rgba(0, 0, 0, 1)"> True;
Result :</span>=<span style="color: rgba(0, 0, 0, 1)"> pnl;
end;
procedure stopWait(pnl: TPanel);
begin
FreeAndNil(pnl);
end;
end.</span></pre>
</div>
<div class="cnblogs_Highlighter">
<pre class="brush:csharp;gutter:true;">procedure Tfgoods.chaxunExecute(Sender: TObject);
begin
var finished: Boolean := False;
ADOQuery1.Close;
ADOQuery1.DisableControls;
var pnl: TPanel := playwait(self);
TThread.CreateAnonymousThread(
procedure
begin
CoInitialize(nil);
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
var sql: string;
var v: string;
if edtId.Text <> '' then
begin
sql := 'select * from t_goods where goodsid = :goodsid';
ADOQuery1.SQL.Add(sql);
v := edtId.Text;
ADOQuery1.Parameters.ParamValues['goodsid'] := v;
end
else if edtPy.Text <> '' then
begin
sql := 'select * from t_goods where isnull(py,'''') like :py';
ADOQuery1.SQL.Add(sql);
v := '%' + edtPy.Text + '%';
ADOQuery1.Parameters.ParamValues['py'] := v;
end
else if edtName.Text <> '' then
begin
sql := 'select * from t_goods where isnull(goodsname,'''') like :goodsname';
ADOQuery1.SQL.Add(sql);
v := '%' + edtName.Text + '%';
ADOQuery1.Parameters.ParamValues['goodsname'] := v;
end
else if edtBarcode.Text <> '' then
begin
sql := 'select * from t_goods where isnull(barcode,'''') = :barcode';
ADOQuery1.SQL.Add(sql);
v := edtBarcode.Text;
ADOQuery1.Parameters.ParamValues['edtBarcode'] := v;
end
else
begin
sql := 'select * from t_goods';
ADOQuery1.SQL.Add(sql);
end;
ADOQuery1.Open;
finished := true; //thread execute finished
CoUninitialize;
end).Start;
while True do //wait for thread execute finished
begin
if finished then
begin
ADOQuery1.EnableControls;
stopWait(pnl);
Break;
end;
Application.ProcessMessages;
TThread.Sleep(1);
end;
end;
</pre>
</div>
<p> </p>
<p><span style="background-color: rgba(255, 255, 255, 1); font-family: "PingFang SC", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px"> </span></p>
<p> </p>
<p> </p>
</div>
<div id="MySignature" role="contentinfo">
<p>本文来自博客园,作者:{咏南中间件},转载请注明原文链接:https://www.cnblogs.com/hnxxcxg/p/16582176.html</p><br><br>
来源:https://www.cnblogs.com/hnxxcxg/p/16582176.html
頁:
[1]