Application.ProcessMessages

2017-06-19 19:44:18来源:CSDN作者:zisongjia人点击

//如果有这样一个循环, 是非常可怕的; 因为它完不了, 你得等着.procedure TForm1.Button1Click(Sender: TObject);var  i: Integer;begin  for i := 0 to MaxInt do  begin    Text := IntToStr(i);  end;end;
//即使这样也无济于事, 因为在循环期间你执行不了 Button2Clickvar b: Boolean;procedure TForm1.Button1Click(Sender: TObject);var i: Integer;begin b := True; for i := 0 to MaxInt do begin if b then Text := IntToStr(i) else Exit; end;end;procedure TForm1.Button2Click(Sender: TObject);begin b := False;end;
//如果在循环期间...for i := 0 to MaxInt do begin if b then Text := IntToStr(i) else Exit; {看看还有其他什么事情发生} end;
//Application.ProcessMessages 就是干这个的!var b: Boolean;procedure TForm1.Button1Click(Sender: TObject);var i: Integer;begin b := True; for i := 0 to MaxInt do begin if b then Text := IntToStr(i) else Exit; Application.ProcessMessages; {!} end;end;procedure TForm1.Button2Click(Sender: TObject);begin b := False;end;

最新文章

123

最新摄影

微信扫一扫

第七城市微信公众平台