pauseu.pas
来自「Delphi Win32核心API参考光盘源码 本书包含了常用的Windows」· PAS 代码 · 共 66 行
PAS
66 行
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 + =
减小字号Ctrl + -
显示快捷键?