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

📄 emulatetimeru.pas

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

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
  StartTick: DWORD;     // holds the start time
begin
  {get the current tick count}
  StartTick := GetTickCount;

  {if the loop is still running...}
  while Running do
  begin
    {...check the elapsed time. if a second has passed...}
    if (GetTickCount-StartTick)>1000 then
    begin
      {...update the label on the form}
      Form1.Label1.Visible := not Form1.Label1.Visible;

      {reinitialize the start time for the next round}
      StartTick := GetTickCount;
    end;

    {this is required so the loop doesn't lock up the machine}
    Application.ProcessMessages;
  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 + -