?? emulatetimeru.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 + -