Delphi 官方 ProcessMessages 用法代码例子


本文整理自网络,侵删。

 
const magicnumber = 500;
procedure TForm1.FormCreate(Sender: TObject);
begin
  Button1.Caption := 'Ignore Messages';
  Button2.Caption := 'Process Messages';
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  I, J: Integer;
  X, Y: Word;
begin
  I := 0;
  J := 0;
  Canvas.TextOut(10, 10, 'The Button1Click handler has started');
  Application.ProcessMessages; // Doing this, you get the message out.
  while I < magicnumber do
  begin
    Randomize;
    while J < magicnumber do
    begin
      Sleep(10);
      Y := Random(J);
      Inc(J);
    end;
    X := Random(I);
    Inc(I);
  end;
  Canvas.TextOut(10, 10, 'The Button1Click handler is finished   ');
end;

procedure TForm1.Button2Click(Sender: TObject);
var
  I, J: Integer;
  X, Y: Word;
begin
  I := 0;
  J := 0;
  Canvas.TextOut(10, 10, 'The Button2Click handler has started');
  while I < magicnumber do
  begin
    Randomize;
    while J < magicnumber do
    begin
      Y := Random(J);
      Inc(J);
      Sleep(10);
      Application.ProcessMessages;
    end;
    X := Random(I);
    Inc(I);
  end;
  Canvas.TextOut(10, 10, 'The Button2Click handler is finished   ');
end;

相关阅读 >>

idhttp控件的防止异常的处理

Delphi 读url下txt中的下载地址的简单下载者代码

Delphi研究之驱动开发篇(五)--使用后备列表

Delphi中使用自定义字体

Delphi idhttp post中文的问题

Delphi richedit选中文字右键菜单的实现

Delphi windows 编程[10] - wm_lbuttondown、wm_lbuttonup 和 wm_mousemove 消息

Delphi winapi: getdesktopwindow - 返回桌面窗口的句柄

Delphi 如何在桌面添加右键菜单

Delphi access 导出 excel 表格

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...