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

📄 killtimeru.pas

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

interface

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

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

{our timer callback prototype. notice the export directive}
procedure TimerProc(hWnd:HWND;uMsg:UINT;idEvent:UINT;Time:DWORD);stdcall;export;

var
  Form1: TForm1;
  DemoCounter: Integer;   // a counter to demonstrate that a timer is running

const
  EXAMPLETIMER = 1;       // a timer identifier

implementation

{$R *.dfm}

{this function is run every time EXAMPLETIMER fires}
procedure TimerProc(hWnd: HWND; uMsg: UINT; idEvent: UINT; Time: DWORD);
begin
  {display a message to show that the timer is running}
  Form1.Label1.Caption := 'Timer1 is Now Running: ' + IntToStr(DemoCounter);

  {increment a counter to show that the timer is running}
  Inc(DemoCounter);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  {reset our counter}
  DemoCounter:= 0;

  {create a timer to fire once per second}
  SetTimer(Form1.Handle,	// handle of window for timer messages
           EXAMPLETIMER,	// timer identifier
           1000,	        // fire every 1000 milliseconds
           @TimerProc 	        // address of timer procedure
           );
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  {remove our example timer}
  KillTimer(Form1.Handle,	// handle of window that installed timer
            EXAMPLETIMER   	// timer identifier
            );

   {clear the caption}
   Label1.Caption := '';
end;


end.

⌨️ 快捷键说明

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