⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pauseu.pas

📁 DelphiWin32核心API参考光盘内容.是学习书籍中的源码,便于学习.
💻 PAS
字号:
unit PauseU;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  Running: Boolean;     // the loop control variable

implementation

{$R *.DFM}

procedure FlashLoop;
var
  PacingCounter: DWORD;     // holds the reference start time
begin
  {if the loop is still running...}
  while Running do
  begin
    {...update the label on the form}
    Form1.Label1.Visible := not Form1.Label1.Visible;

    {pause the loop for one second}
    PacingCounter := GetTickCount;
    repeat
      {Let Windows process any pending messages}
      Application.ProcessMessages;
    until (GetTickCount-PacingCounter) > 1000;

  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  {set the loop control variable...}
  Running := TRUE;

  {...and start the loop}
  FlashLoop;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  {the loop control variable must be set to FALSE
   so the loop will exit and the program can close}
  Running := FALSE;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -