Application.ProcessMessages用法:
我想你可能还有点模糊。举个例子容易明白:假如你的窗体上有两个按钮,一个“计算”,一个“停止”,
如果你的计算是密集运算或复杂处理,当你点了“计算”钮后,你将发现“停止”按钮不会响应你的点击了,
也就是说,你无法随时使计算过程停下来。而倘若你在计算的代码中加入Application.ProcessMessages,则
你的程序就有机会响应其它的事件了。
在大量的循环运算,又不想使用多线程时,为了计算机在运算时能响应用户的操作,
又不破坏指令执行.
所起作用类似于VB中DoEvent方法.
procedure Delay(MSecs: Longint);
//延时函数,MSecs单位为毫秒(千分之1秒)
var
FirstTickCount, Now: Longint;
begin
FirstTickCount := GetTickCount();
repeat
Application.ProcessMessages;
Now := GetTickCount();
until (Now - FirstTickCount >= MSecs) or (Now < FirstTickCount);
end;
分享到:
相关推荐
Application.ProcessMessages作用Application.ProcessMessages作用Application.ProcessMessages作用Application.ProcessMessages作用
Application.ProcessMessages; begin for i:=0 to j do begin form1.Label1.Caption:='正在读取第 '+inttostr(i)+' 包 '; form1.Memo1.Text:=form1.Memo1.Text+ midstr(strtohex(form1.Memo2.text),2048*i,...
while(tag=0) do Application.ProcessMessages; vv := VarArrayCreate([0, 0], varVariant); HTMLDocument := WebBrowser1.Document as IHTMLDocument2; HTMLDocument.Write(PSafeArray(TVarData(vv).VArray...
定时关机,服务控制器,截图工具,清理临时文件, 数据库备份,写字板
Application.ProcessMessages; end; tsList.Add(s); try try ADOQuery.First; While Not ADOQuery.Eof do begin s:=''; for y:=0 to ADOQuery.FieldCount-1 do begin s:=s+ADOQuery.Fields[y].AsString+...
Application.ProcessMessages; end; procedure TFrmProgress.SetProgressMax(const Value: Integer); begin FProgressMax := Value; ProgressBar.Max:=FProgressMax; end; procedure TFrmProgress....
图片的垂直交错效果,Delphi 编写的图片垂直交错显示效果,之前就分享过这种效果,类似百叶窗的交替显示... Application.ProcessMessages; end; form1.Canvas.Draw(0,0,newbmp); i:=i 2; end; newbmp.free;
Delphi演示如何将一张图片的颜色加深,类似于调整对比度,不过本效果不加入了渐变加深的动画效果,按住按钮图片一直变暗下去,要知... Application.ProcessMessages; //让Application去处理消息队伍中的消息 end;
Application.ProcessMessages; SearchFile1(List[I], Edit1.Text); ProgressBar1.Position := I; end; ListBox1.Items.Text := FileNameList.Text; ButtonSearchFile.Caption := IntToStr(FileNamePathList....
批量下载QQ邮箱中的所有附件 procedure TFrm_QQMailRev.bt_revClick(Sender:... application.ProcessMessages; end; Label3.Caption := '共接收附件:['+intToStr(fCount)+'] '; IdPOP31.Disconnect; //断开连接 end;
Application.ProcessMessages; end; end; // 注释和取消注释 // 获得选中的文本的起始行和结束行 procedure TStringFunction.InsertComment(Memo: TMemo); var str: string; x, y: Integer; begin str := ...
unit TreeViewFunctions; interface uses Windows, Messages, SysUtils, Variants, Classes, ComCtrls, Controls, Forms, FileCtrl, StrUtils, Masks, Vcl.... if Application.MessageBox('确定要删除这个文件夹吗...
Application.ProcessMessages; end; end; // we must use the result Total := n2; time2 := Now; Label1.Caption := FormatDateTime ( 'n:ss', Time2-Time1) + ' seconds'; end; 记时这段代码值得一看,...
TIdAntiFreeze在Indy内部定时中断对栈的调用,并在中断期间调用Application.ProcessMessages方法处理消息,而外部的Indy调用继续保存阻塞状态,就好像TIdAntiFreeze对象不存在一样。你只要在程序中的任意地方添加一...
- Added fix for: Possible deadlock when Error Insight calls ProcessMessages 2009-02-18: - Added for for IDE may select the wrong file when performing a ctrl+click on a filename in the editor - ...
,ReadyState,READYSTATE_INTERACTIVE,WebBrowser1.OleObject.document.write(,ProcessMessages;,WebBrowser1.OleObject.document,TreeView1.Items.AddChild(,TreeView1.Selected.AbsoluteIndex,Lines.Text,FindCode...
to multiple recipients, i.e.: ‘a@doma.com, b@domb.com,c@domc.com‘ This change is done for better compatibility with other emails clients.- Better formatting of the field Date of TSakMsg. Some ...
Q434679 - A layout group fires the OnTabChanging event twice if the event's handler calls Application.ProcessMessages Q433283 - A layout group with a label layout item that is set to occupy the ...
•Q580916 - An AV occasionally occurs when calling Application.ProcessMessages within the View's BeginUpdate/EndUpdate block •Q582957 - In Delphi 7, the grid configuration wizard doesn't add data ...
Q434679 - A layout group fires the OnTabChanging event twice if the event's handler calls Application.ProcessMessages Q433283 - A layout group with a label layout item that is set to occupy the entire...